Procházet zdrojové kódy

小程序优化修改

zuypeng před 1 rokem
rodič
revize
3f5bb6f87c

+ 12 - 2
src/components/login-bar/index.vue

@@ -12,7 +12,7 @@
   </view>
 </template>
 <script setup lang="ts" name="loginBar">
-import {login} from "@/utils/auth";
+import {login, tryLogin} from "@/utils/auth";
 import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
 import {reactive} from "vue";
 
@@ -62,9 +62,19 @@ const handleGetPhone = (e:any) => {
 }
 
 const handleGotoLoginPage = () => {
-  uni.navigateTo({
+/*  uni.navigateTo({
     url: '/pages-user/login/index'
+  })*/
+  tryLogin().then((token)=>{
+    console.log(">>>>>>>>>",token)
+
+  }).catch(e=>{
+    console.error("尝试登录失败,跳转登录页注册",e)
+    uni.navigateTo({
+      url: '/pages-user/login/index'
+    })
   })
+
 }
 </script>
 

+ 1 - 27
src/pages-user/agreement/index.vue

@@ -1,10 +1,6 @@
 <template>
   <view class="page">
-    <uv-collapse @change="handleChange" @close="close" @open="open">
-      <uv-collapse-item :title="(index+1)+'.'+item.question" :name="item.question"  v-for="(item, index) in state.questions" :key="index">
-        <uv-parse :content="item.answer" :selectable="true"></uv-parse>
-      </uv-collapse-item>
-    </uv-collapse>
+    <text>用户协议 </text>
   </view>
 </template>
 
@@ -21,17 +17,6 @@ const initState = () => ({
 
 const state = reactive(initState())
 
-const handleChange = () => {
-
-}
-
-const close = () => {
-
-}
-
-const open = () => {
-
-}
 
 const call = () => {
   uni.makePhoneCall({
@@ -39,22 +24,11 @@ const call = () => {
   });
 };
 
-const toggle = (index: number) => {
-  state.questions = state.questions.map((item, i) => {
-    return {
-      ...item,
-      open: item.open ? false : i === index,
-    };
-  });
-};
 
 onShow((options:any) => {
   if (options) {
     state.servicerPhone = options.servicerPhone;
   }
-  body(`/faq/list`).then((res: any) => {
-    state.questions = res.list;
-  })
 });
 
 onHide(() => {

+ 5 - 4
src/pages-user/login/index.vue

@@ -105,12 +105,13 @@ const handleGetPhone = (e:any) => {
     console.log(">>>>>>>>>",token)
     if(redirectUrl.value){
       uni.redirectTo({
-        url:redirectUrl.value
+        url:redirectUrl.value+"?shortId="+shortId.value
       })
     }else{
-      uni.switchTab({
-        url:"/pages/index/index"
-      })
+      uni.navigateBack()
+      // uni.switchTab({
+      //   url:"/pages/index/index"
+      // })
     }
   })
 }

+ 0 - 23
src/pages-user/policy/index.vue

@@ -80,23 +80,11 @@ import {body} from "@/utils/https"
 
 
 const initState = () => ({
-  questions: [] as any[],
   servicerPhone: "",
 })
 
 const state = reactive(initState())
 
-const handleChange = () => {
-
-}
-
-const close = () => {
-
-}
-
-const open = () => {
-
-}
 
 const call = () => {
   uni.makePhoneCall({
@@ -104,22 +92,11 @@ const call = () => {
   });
 };
 
-const toggle = (index: number) => {
-  state.questions = state.questions.map((item, i) => {
-    return {
-      ...item,
-      open: item.open ? false : i === index,
-    };
-  });
-};
 
 onShow((options:any) => {
   if (options) {
     state.servicerPhone = options.servicerPhone;
   }
-  body(`/faq/list`).then((res: any) => {
-    state.questions = res.list;
-  })
 });
 
 onHide(() => {

+ 61 - 40
src/pages-user/wallet/index.vue

@@ -31,21 +31,26 @@
 
       <uv-list>
         <uv-list-item
-            clickable show-arrow :class="item.type!==3?'arrow-hide':''" v-for="(item,index) in dataList" :key="index" @click="handleClickDetail(item)">
+            clickable v-for="(item,index) in dataList" :key="index" @click="handleClickDetail(item)">
           <template #default>
             <view class="wallet-item">
-              <view class="wallet-item_header">
-                <view class="flex-inline">
-                  <text class="wallet-item_header-type">{{ fmtDictName('WalletDetail.type', item.type) }}</text>
-                  <uv-tags class="ml10" style="margin-left: 10px;" size="mini" plain
-                           :type="item.status==0?'primary':(item.status==1?'success':'error')"
-                           :text="fmtDictName('WalletDetail.status', item.status)"></uv-tags>
+              <view class="wallet-item_left">
+                <view class="wallet-item_header">
+                  <view class="flex-inline">
+                    <text class="wallet-item_header-type">{{ fmtDictName('WalletDetail.type', item.type) }}</text>
+                    <uv-tags class="ml10" style="margin-left: 10px;" size="mini" plain
+                             :type="item.status==0?'primary':(item.status==1?'success':'error')"
+                             :text="fmtDictName('WalletDetail.status', item.status)"></uv-tags>
+                  </view>
+                  <text class="wallet-item_header-amt">{{ (item.amount / 100).toFixed(2) }}元</text>
+                </view>
+                <view class="wallet-item_body">
+                  <text class="wallet-item_body-order">{{ item.orderNo }}</text>
+                  <text class="wallet-item_body-time">{{ fmtDateTime(item.transactionTime) }}</text>
                 </view>
-                <text class="wallet-item_header-amt">{{ (item.amount / 100).toFixed(2) }}元</text>
               </view>
-              <view class="wallet-item_body">
-                <text class="wallet-item_body-order">{{ item.orderNo }}</text>
-                <text class="wallet-item_body-time">{{ fmtDateTime(item.transactionTime) }}</text>
+              <view class="wallet-item_right">
+                <uv-icon name="arrow-right" v-if="item.type===3"></uv-icon>
               </view>
             </view>
           </template>
@@ -224,48 +229,64 @@ const handleClickDetail = (walletDetail: any) => {
 
 
     .wallet-item {
-      display: flex;
-      flex-direction: column;
+      display: inline-flex;
+      //flex-direction: column;
       padding: 14rpx;
       border-radius: 8rpx;
       margin: 10rpx 16 prx 10rpx 10rpx;
 
 
-      &_header {
-        display: inline-flex;
-        flex-wrap: nowrap;
-        justify-content: space-between;
+      &_left {
+        flex: 1;
+        flex-direction: column;
 
-        &-type {
-          font-weight: 500;
-          font-size: 14px;
-          margin-right: 15rpx;
-        }
+        .wallet-item_header {
+          width: 100%;
+          display: inline-flex;
+          flex-wrap: nowrap;
+          justify-content: space-between;
 
+          &-type {
+            font-weight: 500;
+            font-size: 14px;
+            margin-right: 15rpx;
+          }
 
-        &-status {
-          font-size: 12px;
-          margin-left: 6px;
-          border: 1px solid $uni-color-primary;
-          border-radius: 2rpx;
-        }
 
-        &-amt {
-          font-weight: 500;
-          font-size: 17px;
+          &-status {
+            font-size: 12px;
+            margin-left: 6px;
+            border: 1px solid $uni-color-primary;
+            border-radius: 2rpx;
+          }
+
+          &-amt {
+            font-weight: 500;
+            font-size: 17px;
+          }
         }
-      }
 
-      &_body {
-        padding: 10rpx 0;
-        display: inline-flex;
-        justify-content: space-between;
+        .wallet-item_body {
+          width: 100%;
+          padding: 10rpx 0;
+          display: inline-flex;
+          justify-content: space-between;
 
-        &-order, &-time {
-          font-size: 12px;
-          color: $uni-color-subtitle
+          &-order, &-time {
+            font-size: 12px;
+            color: $uni-color-subtitle
+          }
         }
       }
+
+      &_right {
+        width: 42rpx;
+        display: flex;
+        align-items: center;
+        align-content: center;
+        justify-content: center;
+      }
+
     }
   }
 
@@ -283,7 +304,7 @@ const handleClickDetail = (walletDetail: any) => {
   }
 }
 
-.arrow-hide{
+.arrow-hide {
   .uv-icon {
     visibility: hidden !important;
   }

+ 5 - 1
src/utils/auth.ts

@@ -127,6 +127,7 @@ export function tryLogin() {
             resolve(ftoken)
             return;
         }
+        uni.showLoading()
         uni.login({
             success: (res) => {
                 let data = {
@@ -148,12 +149,15 @@ export function tryLogin() {
                         //     errMsg:  `${JSON.stringify(res)}`,
                         // });
                     }
+                    uni.hideLoading()
                 }).catch(e => {
                     reject(e)
+                    uni.hideLoading()
                 })
             },
             fail: function () {
                 reject('fail')
+                uni.hideLoading()
             },
         });
     }))
@@ -168,7 +172,7 @@ export function checkLogin() {
                 icon: "none",
                 title: "请先登录",
             });
-            reject();
+            reject('未获取到用户登录信息');
         } else {
             resolve(user);
         }

+ 5 - 1
src/utils/common.ts

@@ -100,7 +100,7 @@ export function fmtDateTime(date: any) {
     if (!date) {
         return "";
     }
-    date = new Date(date);
+    date = new Date(formatDateForIOS(date));
     const year = date.getFullYear();
     const month = date.getMonth() + 1;
     const day = date.getDate();
@@ -111,6 +111,10 @@ export function fmtDateTime(date: any) {
     return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
 };
 
+function formatDateForIOS(dateString:string) {
+    return dateString.replace(/-/g, '/');
+}
+
 
 const formatNumber = n => {
     n = n.toString();