chenlei пре 1 година
родитељ
комит
f31cfbc6f2

+ 38 - 15
src/App.vue

@@ -1,23 +1,46 @@
 <script setup lang="ts">
-onLaunch(() => {
-  //   uni.hideHomeButton()
+onLaunch(async () => {
+  // #ifdef MP
+
   store.common.data.mockScenes = ''
+  // 容器中心需要等待的等待放行器
+  store.common.data._releaser = func.releaser()
+  const accountInfo = uni.getAccountInfoSync()
+  // 体验版-假数据方便通过审核
+  if (accountInfo?.miniProgram?.envVersion === 'trial') {
+    store.user.initUserInfo(
+      mock.request[config.common.mockScenes.examine][config.webapi.user.token.name].data,
+    )
+    store.common.data.mockScenes = config.common.mockScenes.examine
+  } else {
+    store.common.data.mockScenes = ''
+  }
+  store.common.data._releaser.s()
+  store.common.data._releaser = null
+  // #endif
+
+  // await webapi.strategy
+  //   .get_by_Name<null, SystemConfig对象>({
+  //     // name: 'examine_switch',
+  //     name: 'examine_switch1',
+  //   })
+  //   .then((res) => {
+  //     // 开关打开时 设置场景值
+  //     if (res.value === '1') {
+  //       store.user.initUserInfo(
+  //         mock.request[config.common.mockScenes.examine][config.webapi.user.token.name].data,
+  //       )
+  //       store.common.data.mockScenes = config.common.mockScenes.examine
+  //     } else {
+  //       store.common.data.mockScenes = ''
+  //     }
+  //   })
+  //   .catch(() => {
+  //     store.common.data.mockScenes = ''
+  //   })
 })
 onShow((options) => {
   // ay.staticData.args.options = options
-  webapi.strategy
-    .mina_fake()
-    .then((res) => {
-      // 开关打开时 设置场景值
-      if (res) {
-        store.common.data.mockScenes = config.common.mockScenes.examine
-      } else {
-        store.common.data.mockScenes = ''
-      }
-    })
-    .catch(() => {
-      store.common.data.mockScenes = ''
-    })
 })
 // onHide(() => {
 //   console.log('App Hide')

+ 2 - 5
src/components/business/carNumber.vue

@@ -9,7 +9,7 @@
         <div class="cn-center">
           <div class="input_box">
             <template v-for="(n, i) in cnumbers" :key="i">
-              <div class="ibitem" :class="{ active: n.active, green: i === cnumbers.length - 1 }">
+              <div class="ibitem" :class="{ active: n.active }">
                 {{ n.value }}
               </div>
               <span class="center point" v-if="n.afterPoint">•</span>
@@ -319,7 +319,7 @@ defineExpose(methods)
       text-align: center;
       border: 1rpx solid #ced0d2;
       border-radius: $p-spacd2;
-      &.green {
+      &:last-child {
         background-color: #9eefa4;
       }
       &.active::after {
@@ -339,9 +339,6 @@ defineExpose(methods)
       width: $p-spac;
       color: $gray-color;
     }
-    li:last-child {
-      background-color: #9eefa4;
-    }
 
     // 动态样式
     .li_focus {

+ 10 - 1
src/components/pull/index.vue

@@ -8,7 +8,16 @@
       <slot />
     </van-list>
     <!-- #endif -->
-    <uni-load-more :status="status" :content-text="contentText" />
+    <!-- <uni-load-more :status="status" :content-text="contentText" /> -->
+    <div class="center s-fz">
+      <uni-load-more :status="status" :content-text="contentText" />
+      <ay-refresh
+        v-if="store.curPage.pagerInfo.error"
+        :loading="store.curPage.pagerInfo.loading"
+        text="重试"
+        @refresh="store.curPage.pagerMethods.refresh({ isAdd: store.curPage.pagerInfo.isAdd })"
+      ></ay-refresh>
+    </div>
   </div>
 </template>
 <script lang="ts" setup>

+ 3 - 2
src/components/refresh/index.vue

@@ -8,13 +8,14 @@
       :customPrefix="rotaterMp"
       :style="{ 'font-size': props.iconSize + 'rpx' }"
     ></uni-icons>
-    刷新
+    {{ props.text }}
   </div>
 </template>
 <script lang="ts" setup>
 const emits = defineEmits(['refresh'])
-const props = withDefaults(defineProps<{ loading: boolean; iconSize: number }>(), {
+const props = withDefaults(defineProps<{ loading: boolean; iconSize: number; text?: string }>(), {
   iconSize: 30,
+  text: '刷新',
 })
 const rotaterH5 = computed(() => {
   let rv = ''

+ 22 - 4
src/pages/index/index.vue

@@ -9,13 +9,17 @@
             <div class="mobile">{{ store.user.userInfo.mobileDes }}</div>
           </div>
         </div>
-        <uni-icons
+        <div class="text-center" @click="methods.scanCode">
+          <image src="@img/icons/scan_icon.png" mode="scaleToFill" class="scan mt-spacd4" />
+          <div class="p-color s-fz mt-spacd2">扫一扫</div>
+        </div>
+        <!-- <uni-icons
           type="scan"
           color=""
           class="p-color"
           size="40"
           @click="methods.scanCode"
-        ></uni-icons>
+        ></uni-icons> -->
       </div>
       <div class="center">
         <ay-flowLine
@@ -115,6 +119,15 @@
           :key="i"
           :stationInfo="la"
         ></ayb-station>
+        <!-- <div v-if="store.webapi.strategy.list_mini.fail" class="center">
+          加载失败
+          <ay-refresh
+            :iconSize="36"
+            :loading="store.webapi.strategy.list_mini.ing"
+            text="重试"
+            @refresh="methods.getListApp"
+          ></ay-refresh>
+        </div> -->
       </div>
       <div
         class="center p-color"
@@ -334,6 +347,7 @@ const methods = ay.initMethods(
       maps[menu.id]()
     },
     drawerOpen() {
+      methods.getCityList()
       drawer.value.open()
       data.station.indexedListShow = true
       // 解决uni-indexed-list 组件滑动失效问题
@@ -549,7 +563,7 @@ const methods = ay.initMethods(
         })
     },
     getCityList() {
-      webapi.strategy.city_list().then((res) => {
+      return webapi.strategy.city_list().then((res) => {
         res.unshift({ text: staticData.defCity, children: [{ text: staticData.defCity }] })
         data.station.cityList = res.map((m) => {
           return {
@@ -560,7 +574,7 @@ const methods = ay.initMethods(
       })
     },
     async getListApp({
-      cras = config.common.defAyContainerRefreshArgs,
+      cras = store.curPage.getDefAyContainerRefreshArgs(),
       activation = false,
       // checkScope = false,
     } = {}) {
@@ -765,4 +779,8 @@ $bgc: rgba($p-color, 0.4);
   font-size: $bs-fz;
   color: unset;
 }
+.scan {
+  width: 50rpx;
+  height: 50rpx;
+}
 </style>

+ 3 - 3
src/pages/order/createOrder.vue

@@ -26,8 +26,8 @@
       <button
         type="primary"
         @click="methods.confirm"
-        :loading="store.webapi.pay.add.ing"
-        :disabled="store.webapi.pay.add.ios"
+        :loading="store.webapi.pay.add_v2.ing"
+        :disabled="store.webapi.pay.add_v2.ios"
       >
         确定
       </button>
@@ -87,7 +87,7 @@ ay.entrance(async (args) => {
   })
 })
 onUnload(() => {
-  store.webapi.pay.add.set()
+  store.webapi.pay.add_v2.set()
 })
 </script>
 

+ 1 - 1
src/pages/order/index.vue

@@ -258,7 +258,7 @@ const methods = {
       realfg.items[0].checked = false
     }
   },
-  getOrderList(cras = config.common.defAyContainerRefreshArgs) {
+  getOrderList(cras = store.curPage.getDefAyContainerRefreshArgs()) {
     const paramFilters: Record<string, string> = {}
     const storeFilterCheckeds = methods.getStoreFilterCheckeds()
     Object.keys(storeFilterCheckeds).forEach(

+ 2 - 2
src/pages/order/orderDetail.vue

@@ -237,7 +237,7 @@ const data = ay.initData({
           title: '交易模式',
           key: 'tradeType',
           view(data) {
-            return config.common.tradeType[data]
+            return func.convert.getTradeTypeStr(data)
           },
         },
       ],
@@ -366,7 +366,7 @@ ay.entrance((args) => {
   webapi.strategy
     .get_order_detail({ orderId: store.curPage.pageConfig.params.orderId, orderType: 1 })
     .then((res) => {
-      data.title = '加气订单 · ' + config.common.settleStatus[res.settleStatus]
+      data.title = '加气订单 · ' + func.convert.getOrderStatusStr(res.settleStatus)
       // store.curPage.pageConfig.title = '加气订单 · ' + config.common.settleStatus[res.settleStatus]
       // uni.setNavigationBarTitle({ title: store.curPage.pageConfig.title })
 

+ 11 - 3
src/pages/order/prePay.vue

@@ -20,7 +20,9 @@
         <div>
           <div class="font-bold inline" @click="methods.choose(0)">个人支付</div>
           <div class="ml-spacd2 mt-spacd2">
-            结算金额 ¥ {{ personPay?.amount }} 元 (结算价 ¥ {{ personPay?.actualPrice }} 元/公斤)
+            结算金额
+            <ay-numer :value="personPay?.amount" pre="¥" unit="元" />
+            (结算价 ¥ {{ personPay?.actualPrice }} 元/公斤)
           </div>
         </div>
       </div>
@@ -34,7 +36,9 @@
           <div class="font-bold inline" @click="methods.choose(1)">所属物流支付</div>
           <div class="childs-fc-mbd2 ml-spacd2 mt-spacd2">
             <div @click="methods.switchRebateDetail">
-              结算金额 ¥ {{ carrierPay.amount }} 元 (结算价 ¥
+              结算金额
+              <ay-numer :value="carrierPay?.amount" pre="¥" unit="元" />
+              (结算价 ¥
               {{ carrierPay.actualPrice }} 元/公斤)
             </div>
             <span v-if="carrierPay.carrierRebate">
@@ -59,7 +63,11 @@
             <div class="pt-spacd2 top-line">{{ carrierPay.carrierOrgName }}</div>
             <div>[{{ carrierPay.carNumber }}]</div>
             <div class="justify-start" v-if="carrierPay.balanceEnable">
-              <div>可用余额 {{ carrierPay.balanceStr }}元</div>
+              <div>
+                可用余额
+                <span class="font-bold">{{ carrierPay.balanceStr }}</span>
+                元
+              </div>
               <ay-refresh
                 :loading="store.webapi.strategy.paysel.ing"
                 @refresh="methods.paysel"

+ 1 - 1
src/pages/truckInfo/detail.vue

@@ -39,7 +39,7 @@ const data = ay.initData({
           title: '加气交易模式',
           key: 'tradeType',
           view(value) {
-            return config.common.tradeType[value]
+            return func.convert.getTradeTypeStr(value)
           },
         },
       ],

BIN
src/static/images/icons/scan_icon.png


+ 1 - 1
src/utils/aop/index.ts

@@ -30,7 +30,7 @@ export default {
 
         if (res.orgId) {
           accountInfo.unit = '元'
-          if (res.autoAccount === 1 && res.flag === 1) {
+          if (res.autoAccount === 1 && res.flag === 1 && res.linked === 0) {
             accountInfo.showBalance = `> ${res.limitAmount}`
           } else {
             accountInfo.showDet = true

+ 15 - 10
src/utils/api/web/request/afterReturning.ts

@@ -14,17 +14,22 @@ export default {
     // }
     // 分页接口自动通知容器,数据加载完毕
     if (store.curPage?.pageConfig?.isPager) {
-      let pages = config.common.defAyContainerRefreshArgs.pages
-      if (func.hasProps(args.res.data, config.common.IPageProps)) {
-        pages = args.res.data.pages
+      // 是分页接口
+      if (func.hasProps(args.options.uur.data, config.common.IPageParams)) {
+        let pages = null
+        if (func.hasProps(args.res.data, config.common.IPageProps)) {
+          pages = args.res.data.pages
+        }
+        if (func.hasProps(args.res.data?.page, config.common.IPageProps)) {
+          pages = args.res.data.page.pages
+        }
+        if (!func.isnull(pages)) {
+          ay.containerLoaded({
+            reqState: enums.ReqState.success,
+            pages,
+          })
+        }
       }
-      if (func.hasProps(args.res.data?.page, config.common.IPageProps)) {
-        pages = args.res.data.page.pages
-      }
-      ay.containerLoaded({
-        reqState: enums.ReqState.success,
-        pages,
-      })
     }
     return args.res.data
   },

+ 8 - 0
src/utils/api/web/request/afterThrowing.ts

@@ -61,6 +61,14 @@ export default {
         res: args.res,
       }
       rv = Promise.reject(pcr)
+      // 分页接口自动通知容器,数据加载失败
+      if (store.curPage?.pageConfig?.isPager) {
+        if (func.hasProps(args.options.uur.data, config.common.IPageParams)) {
+          ay.containerLoaded({
+            reqState: enums.ReqState.fail,
+          })
+        }
+      }
     }
 
     return rv

+ 1 - 1
src/utils/api/web/request/index.ts

@@ -26,7 +26,7 @@ const setRequestResult = ({ options, resolve, reject }) => {
 
 const http = async <T>(options: IRequestOption) => {
   if (store.common.data.mockScenes) {
-    const curMocks = mock.request()
+    const curMocks = mock.request
     const curMock = curMocks[store.common.data.mockScenes][options.urlObj.name]
     if (curMock) {
       // store.webapi[options.urlObj.group][options.urlObj.name].set(enums.ReqState.success)

+ 35 - 16
src/utils/config/index.ts

@@ -30,7 +30,7 @@ const common = {
    * 1.无任何信息 2.显示物流公司信息 3.显示退出申请 4.显示加入申请 5.显示预添加信息
    */
   get safeAreaTopHeight() {
-    return (config.common.SystemInfo.statusBarHeight || 40) + 44
+    return (config.common.SystemInfo?.statusBarHeight || 40) + 44
     // return config.common.SystemInfo.safeArea.top + 44
   },
   get orgDetailType() {
@@ -67,16 +67,28 @@ const common = {
   },
   /** 结算状态 */
   get settleStatus() {
-    return {
-      1: '待支付',
-      7: '支付异常',
-      4: '支付中',
-      2: '已支付',
-      3: '已取消',
-      6: '已退款',
-      5: '退款中',
-      10: '其他',
-    }
+    // 为了与原型顺序一致 采用数组
+    return [
+      { value: '1', label: '待支付' },
+      { value: '7', label: '支付异常' },
+      { value: '4', label: '支付中' },
+      { value: '2', label: '已支付' },
+      { value: '3', label: '已取消' },
+      { value: '6', label: '已退款' },
+      { value: '5', label: '退款中' },
+      { value: '10', label: '其他' },
+    ]
+
+    // return {
+    //   1: '待支付',
+    //   7: '支付异常',
+    //   4: '支付中',
+    //   2: '已支付',
+    //   3: '已取消',
+    //   6: '已退款',
+    //   5: '退款中',
+    //   10: '其他',
+    // }
   },
   /** 支付方式-用于筛选条件 */
   get payTypes() {
@@ -102,11 +114,17 @@ const common = {
   },
   /** 交易模式 */
   get tradeType() {
-    return {
-      1: '大象经销',
-      2: '大象直销',
-      10: '其他',
-    }
+    return [
+      { value: '2', label: '大象直销' },
+      { value: '1', label: '大象经销' },
+      { value: '10', label: '其他' },
+    ]
+
+    // return {
+    //   1: '大象经销',
+    //   2: '大象直销',
+    //   10: '其他',
+    // }
   },
   _SystemInfo: null as UniNamespace.GetSystemInfoResult,
   get SystemInfo() {
@@ -115,6 +133,7 @@ const common = {
     }
     return this._SystemInfo
   },
+  IPageParams: ['page', 'size', 'param'],
   IPageProps: ['current', 'pages', 'total', 'records'],
   /** 分页组件加载数据事件参数默认值 */
   get defAyContainerRefreshArgs() {

+ 22 - 8
src/utils/container/index.ts

@@ -146,15 +146,24 @@ export default {
       store.curPage.initPageInfo()
       let isLogined = true
       const curPage = store.curPage.pageConfig
-      if (curPage.identity) {
-        if (!store.user.isLogined) {
-          isLogined = false
-          ay.goLogin()
+      if (store.common.data._releaser) {
+        store.common.data._releaser.p.then(() => {
+          if (curPage.identity) {
+            if (!store.user.isLogined) {
+              isLogined = false
+              ay.goLogin()
+            }
+          }
+        })
+      } else {
+        if (curPage.identity) {
+          if (!store.user.isLogined) {
+            isLogined = false
+            ay.goLogin()
+          }
         }
       }
-      if (isLogined) {
-        uni.setNavigationBarTitle({ title: store.curPage.pageConfig.title })
-      }
+      uni.setNavigationBarTitle({ title: store.curPage.pageConfig.title })
 
       return isLogined
     }
@@ -162,7 +171,7 @@ export default {
     onUnload(() => {
       store.curPage.removeCurPagerInfo()
     })
-    onLoad(() => {
+    onLoad(async () => {
       if (!func.antiShake({ func: init, immediately: true, mark: tempid })) {
         return
       }
@@ -175,6 +184,7 @@ export default {
           args.loadType = enums.LoadType.refresh
           callBack(args)
         }
+        // 在onload中 初始化原生方法时,之前的代码不能有await,否则小程序环境'重新进入小程序' 无法触发
         onReachBottom(() => {
           store.curPage.pagerMethods.refresh({ isAdd: true })
         })
@@ -190,6 +200,10 @@ export default {
       // if (options) {
       //   args.options = options
       // }
+      // 等待数据开关接口
+      if (store.common.data._releaser) {
+        await store.common.data._releaser.p
+      }
       callBack(args)
     })
 

+ 12 - 5
src/utils/func/convert.ts

@@ -8,18 +8,25 @@ export default {
   },
   getOrderStatusStr(settleStatus) {
     const map = config.common.settleStatus
-    return map[settleStatus]
+    return map.find((f) => f.value === String(settleStatus))?.label
+  },
+  getTradeTypeStr(tradeType) {
+    const map = config.common.tradeType
+    return map.find((f) => f.value === String(tradeType))?.label
   },
   getCheckItem(obj, filterFunc = (f?) => true) {
-    const arr = Object.keys(obj)
-
-      .map((m) => {
+    let arr: any = []
+    if (obj.push) {
+      arr = obj
+    } else {
+      arr = Object.keys(obj).map((m) => {
         return {
           value: m,
           label: obj[m],
-          checked: false,
         }
       })
+    }
+    arr.forEach((f) => (f.checked = false))
     arr.unshift({
       value: '-1',
       label: '全部',

+ 3 - 1
src/utils/func/index.ts

@@ -82,7 +82,9 @@ export default {
     this._timers[si] = si
     return si
   },
-  /** 延迟器 */
+  /** 延迟器
+   * @params timeout:延迟多少ms ,默认 1000
+   */
   async awaiter(timeout: number = 1000) {
     return new Promise((resolve) => {
       setTimeout(() => {

+ 4 - 4
src/utils/mock/index.ts

@@ -1,5 +1,5 @@
 export default {
-  request() {
+  get request() {
     const mockScenes = {}
     const examine = (mockScenes[config.common.mockScenes.examine] = {})
     examine[config.webapi.strategy.list_mini.name] = {
@@ -7,13 +7,13 @@ export default {
       message: '成功!',
       data: {
         records: [],
-        total: 164,
+        total: 0,
         size: 10,
         current: 1,
         orders: [],
         hitCount: false,
         searchCount: true,
-        pages: 17,
+        pages: 0,
       },
     }
     examine[config.webapi.strategy.get_order_list.name] = {
@@ -163,7 +163,7 @@ export default {
           user_id: '600639400291614720',
           user_code: null,
           user_name: '大象用户_o2o2ym1xL',
-          mobile: '15966870564',
+          mobile: '',
           open_id: 'osPD05Lj_cfxRbE6iUo86xVGyYeE',
           head_url: null,
           login_type: 2,

+ 2 - 0
src/utils/store/common.ts

@@ -9,6 +9,8 @@ export default defineStore('common', () => {
     phone: '400-016-5388',
     /** mock场景值 */
     mockScenes: '',
+    /** 等待放行器 */
+    _releaser: null as GetReturnType<typeof func.releaser>,
   })
   return {
     data,

+ 12 - 4
src/utils/store/curPage.ts

@@ -42,7 +42,7 @@ const pagerMethods = {
   },
   // #endif
   loaded(args) {
-    // 请求成功 再判断所有数据加载完毕
+    // 取消加载效果
     if (args?.reqState === enums.ReqState.cancel) {
       pagerInfo.value.loading = false
       return
@@ -67,9 +67,12 @@ const pagerMethods = {
     }
     pagerInfo.value.error = args.reqState === enums.ReqState.fail
 
-    // 请求失败 page-1
+    // 请求失败
     if (pagerInfo.value.error) {
-      pagerInfo.value.page--
+      // 上拉加载 page-1
+      if (pagerInfo.value.isAdd) {
+        pagerInfo.value.page--
+      }
     }
     // 请求成功 再判断所有数据加载完毕
     if (args.reqState === enums.ReqState.success) {
@@ -85,7 +88,7 @@ const pagerMethods = {
       return
     }
     pagerInfo.value.loading = true
-    pagerInfo.value.error = false
+    // pagerInfo.value.error = false
     pagerInfo.value.isAdd = args.isAdd
     if (args.isAdd) {
       pagerInfo.value.page += 1
@@ -172,6 +175,11 @@ export default defineStore(
           ...curPageInfo,
         } as ayPage
       },
+      /** 获取分页组件加载数据事件参数默认值 */
+      getDefAyContainerRefreshArgs() {
+        store.curPage.pagerInfo.isAdd = config.common.defAyContainerRefreshArgs.isAdd
+        return config.common.defAyContainerRefreshArgs
+      },
       // pageConfigs,
       /** 当前页面配置信息 */
       pageConfig,

+ 2 - 1
src/utils/store/user.ts

@@ -24,7 +24,7 @@ const useUserStore = defineStore(
     const userInfo = ref<TUser>({ ...initState })
 
     const isLogined = computed(() => !!userInfo.value.token)
-    /** 设置用户信息 */
+    /** 初始化用户信息 */
     const initUserInfo = (val: Token认证返回实体) => {
       const data = { ...val.user }
       delete data.authorities
@@ -44,6 +44,7 @@ const useUserStore = defineStore(
         `${service}:${userInfo.value.orgId}:${userInfo.value.user_id}:${userInfo.value.roleId}`,
       )
     }
+    /** 设置部分用户信息 */
     const setUserInfo = (ui: User对象) => {
       if (ui.userName) {
         userInfo.value.user_name = ui.userName