index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. <template>
  2. <ay-container>
  3. <div class="chunk p-b-0">
  4. <div class="center justify-between top">
  5. <div class="center" @click="methods.goPerson">
  6. <image class="personal" :src="store.user.userInfo.head_url" mode="scaleToFill" />
  7. <div :class="{ 'p-color': !store.user.isLogined }">
  8. <div>{{ store.user.userInfo.user_name }}</div>
  9. <div class="mobile">{{ store.user.userInfo.mobileDes }}</div>
  10. </div>
  11. </div>
  12. <div class="text-center" @click="methods.scanCode">
  13. <image src="@img/icons/scan_icon.png" mode="scaleToFill" class="scan mt-spacd4" />
  14. <div class="p-color s-fz mt-spacd2">扫一扫</div>
  15. </div>
  16. <!-- <uni-icons
  17. type="scan"
  18. color=""
  19. class="p-color"
  20. size="40"
  21. @click="methods.scanCode"
  22. ></uni-icons> -->
  23. </div>
  24. <div class="center">
  25. <ay-flowLine
  26. class="mt-spac mb-spac"
  27. :lineWidth="4"
  28. :loading="store.webapi.strategy.get_user_qrcode.ing"
  29. >
  30. <div class="qrcode">
  31. <image
  32. src="@img/qr@3x.png"
  33. class="image"
  34. mode="aspectFit"
  35. v-if="data.hasnopayfordriver || data.qrcode.expire"
  36. @click="methods.getQrcode"
  37. />
  38. <image :src="data.qrcode.img" class="image" mode="aspectFit" v-else />
  39. </div>
  40. </ay-flowLine>
  41. </div>
  42. <div class="center qrcode-text mb-spac" v-if="!data.firstUnload">
  43. <template v-if="data.hasnopayfordriver">存在未支付完成订单</template>
  44. <template v-else-if="data.qrcode.expire">
  45. 二维码已失效
  46. <ay-refresh
  47. :iconSize="36"
  48. :loading="store.webapi.strategy.get_user_qrcode.ing"
  49. @refresh="methods.getQrcode"
  50. ></ay-refresh>
  51. </template>
  52. <template v-else>
  53. 有效时间:
  54. <ay-countdown :seconds="data.qrcode.seconds" @ender="data.qrcode.expire = true" />
  55. </template>
  56. </div>
  57. </div>
  58. <div class="flex">
  59. <ay-flowLine class="flex-1 mr-spac" :loading="store.webapi.strategy.get_driver_balance.ing">
  60. <div class="chunk m0 h-100% s-fz money-bg" @click="methods.goAccount">
  61. <div class="mb-spacd4">
  62. 可用余额
  63. <div class="inline yellow-color ss-fz ml-spacd4" v-if="data.accountInfo.flag === 0">
  64. [余额不足]
  65. </div>
  66. </div>
  67. <ay-numer :value="data.accountInfo.showBalance" :unit="data.accountInfo.unit" />
  68. </div>
  69. </ay-flowLine>
  70. <ay-flowLine class="flex-1" :loading="store.webapi.strategy.get_truck_info.ing">
  71. <div class="chunk m0 h-100% s-fz cars" @click="methods.truckManage">
  72. <div>
  73. <div class="mb-spacd4" v-show="showcm">车辆管理</div>
  74. <div v-if="!store.user.isLogined">{{ config.common.nullView[0] }}</div>
  75. <div v-show="store.webapi.strategy.get_truck_info.firstSuccess">
  76. <div class="p-color mt-spac" v-if="data.truckInfo.length === 0">添加车辆</div>
  77. <div v-else>
  78. <span class="font-bold b-fz">{{ data.truckInfo.length }}</span>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </ay-flowLine>
  84. </div>
  85. <div class="center justify-around mt-spacm2">
  86. <div
  87. class="text-center menu"
  88. v-for="(m, i) in data.menus"
  89. :key="i"
  90. @click="methods.goPage(m)"
  91. >
  92. <img class="icon" :src="m.icon" />
  93. <div>{{ m.name }}</div>
  94. </div>
  95. </div>
  96. <div class="chuck list-app">
  97. <ay-sticky :top="0" relativeTo="#stations" targetSelector="#stationTop">
  98. <div
  99. class="center justify-between sticky"
  100. id="stationTop"
  101. :class="{ stickyed: data.station.stickyed }"
  102. @click="methods.hiddenDoora"
  103. >
  104. <div class="title" @click.stop="methods.hiddenDoorb">附近加气站</div>
  105. <div v-if="data.userLocation" @click="methods.drawerOpen">
  106. {{ data.station.curCity }}
  107. <uni-icons type="down" size="12" />
  108. </div>
  109. </div>
  110. </ay-sticky>
  111. <div v-show="data.userLocation" id="stations">
  112. <ay-flowLine :minLoadTime="400" :loading="store.webapi.strategy.list_mini.ing">
  113. <div style="height: 2rpx"></div>
  114. </ay-flowLine>
  115. <ayb-station
  116. v-for="(la, i) in data.station.listApp"
  117. :key="i"
  118. :isLast="i === data.station.listApp.length - 1"
  119. :stationInfo="la"
  120. ></ayb-station>
  121. <!-- <div v-if="store.webapi.strategy.list_mini.fail" class="center">
  122. 加载失败
  123. <ay-refresh
  124. :iconSize="36"
  125. :loading="store.webapi.strategy.list_mini.ing"
  126. text="重试"
  127. @refresh="methods.getListApp"
  128. ></ay-refresh>
  129. </div> -->
  130. </div>
  131. <div
  132. class="center p-color"
  133. v-show="!data.userLocation"
  134. @click="methods.getListApp({ activation: true })"
  135. >
  136. 查看附近加气站
  137. </div>
  138. </div>
  139. <uni-popup ref="inputDialog" type="dialog">
  140. <uni-popup-dialog
  141. mode="input"
  142. title="邀请通知"
  143. confirmText="加入"
  144. cancelText="拒绝"
  145. :beforeClose="true"
  146. @confirm="methods.agree"
  147. @close="methods.disagree"
  148. >
  149. <div class="text-center w-100%">
  150. <div class="mb-spacd2 text-center">
  151. 【{{ data.invite?.org?.orgName }}】邀请您加入成为其司机
  152. <span class="p-color" @click="methods.phone(data.invite?.org?.mobile)">
  153. <uni-icons type="phone" color="" class="mr-spacd4" size="none"></uni-icons>
  154. <span>{{ data.invite?.org?.mobile }}</span>
  155. </span>
  156. </div>
  157. </div>
  158. </uni-popup-dialog>
  159. </uni-popup>
  160. <!-- 城市列表抽屉 -->
  161. <ay-drawer
  162. ref="drawer"
  163. mode="right"
  164. :maskClick="true"
  165. :width="320"
  166. :top="topHeightPX"
  167. @change="methods.drawerChange"
  168. >
  169. <uni-indexed-list
  170. :options="data.station.cityList"
  171. :show-select="false"
  172. @click="methods.changeCity"
  173. ref="indexedList"
  174. v-if="data.station.indexedListShow"
  175. />
  176. </ay-drawer>
  177. <ayb-carNumber ref="carNumber" />
  178. </ay-container>
  179. </template>
  180. <script lang="ts" setup>
  181. import stompSocket from '@/utils/api/socket/stomp'
  182. import perpay from '@img/icons/perpay.png'
  183. import payhistory from '@img/icons/payhistory.png'
  184. import firm from '@img/icons/firm.png'
  185. import card from '@img/icons/card.png'
  186. const drawer = ref()
  187. const indexedList = ref()
  188. const carNumber = ref()
  189. const inputDialog = ref()
  190. const staticData = {
  191. /** 选择的城市 缓存key名 */
  192. cctkn: 'chooseCity',
  193. /** 默认选择城市 */
  194. defCity: '全部',
  195. /** websocket 实例 */
  196. client: null,
  197. // entranceArgs: null as AyContainerEntryArgs,
  198. /** 临时记录位置信息 */
  199. location: { longitude: '', latitude: '' } as any,
  200. indexedListShowed: false,
  201. /** 索引组件数据监听器 */
  202. indexedListWatcher: null,
  203. /** 页面滚动距离 */
  204. scrollTop: 0,
  205. /** 需要登录的方法名 */
  206. IdentityMethods: [
  207. 'goPerson',
  208. 'scanCode',
  209. 'getQrcode',
  210. 'goAccount',
  211. 'truckManage',
  212. 'goPage',
  213. ] as (keyof typeof methods)[],
  214. }
  215. const data = ay.initData({
  216. loading: false,
  217. /** 未load */
  218. firstUnload: true,
  219. /** 存在未支付完成订单 */
  220. hasnopayfordriver: true,
  221. invite: {} as 预添加司机详情,
  222. truckInfo: [] as PersonDriver对象[],
  223. accountInfo: {} as IAccountInfo,
  224. /** 用户已授权定位 */
  225. userLocation: false,
  226. /** 二维码相关 */
  227. qrcode: {
  228. /** 有效时长 m */
  229. seconds: 300,
  230. /** 二维码 */
  231. img: null,
  232. /** 已过期 */
  233. expire: true,
  234. },
  235. /** 菜单列表 */
  236. menus: [
  237. {
  238. id: 0,
  239. icon: perpay,
  240. name: '待支付订单',
  241. },
  242. {
  243. id: 1,
  244. name: '加气订单',
  245. icon: payhistory,
  246. },
  247. {
  248. id: 2,
  249. name: '所属物流',
  250. icon: firm,
  251. },
  252. {
  253. id: 3,
  254. name: '优惠省钱',
  255. icon: card,
  256. },
  257. ],
  258. station: {
  259. /** 头部已吸顶 */
  260. stickyed: false,
  261. cityList: [] /** 附近加气站列表 */,
  262. curCity: staticData.defCity,
  263. listApp: [],
  264. indexedListShow: false,
  265. },
  266. hiddenDoor: [],
  267. })
  268. const topHeight = computed(() => config.common.safeAreaTopHeight)
  269. const topHeightPX = computed(() => `${topHeight.value}px`)
  270. const showcm = computed(() => {
  271. return (
  272. !store.webapi.strategy.get_truck_info.firstSuccess ||
  273. (store.webapi.strategy.get_truck_info.firstSuccess && data.truckInfo.length)
  274. )
  275. })
  276. const methods = ay.initMethods(
  277. {
  278. hiddenDoorb() {
  279. data.hiddenDoor[data.hiddenDoor.length - 1]++
  280. },
  281. hiddenDoora() {
  282. if (
  283. data.hiddenDoor[0] === 3 &&
  284. data.hiddenDoor[1] === 1 &&
  285. data.hiddenDoor[2] === 2 &&
  286. data.hiddenDoor[3] === 4
  287. ) {
  288. data.hiddenDoor = []
  289. uni.setClipboardData({
  290. data: JSON.stringify({ userInfo: store.user.userInfo }),
  291. })
  292. } else {
  293. data.hiddenDoor.push(0)
  294. }
  295. },
  296. phone(num) {
  297. uni.makePhoneCall({
  298. phoneNumber: num,
  299. })
  300. },
  301. getTruckInfo() {
  302. webapi.strategy.get_truck_info({}).then((res) => {
  303. data.truckInfo = aop.request.AR.truckInfo(res)
  304. })
  305. },
  306. truckManage() {
  307. if (store.common.data.mockScenes === config.common.mockScenes.examine) {
  308. return
  309. }
  310. if (data.truckInfo.length) {
  311. ay.goPage(config.pages.truckInfo_index)
  312. } else {
  313. carNumber.value.open().then((cn) => {
  314. if (store.webapi.strategy.bind_person_truck.ing) {
  315. return
  316. }
  317. webapi.strategy
  318. .bind_person_truck<{ userId: string }>({
  319. userId: store.user.userInfo.user_id,
  320. newCarNumber: cn,
  321. })
  322. .then((res) => {
  323. if (res) {
  324. func.native.showToast('添加成功')
  325. methods.getTruckInfo()
  326. }
  327. })
  328. })
  329. }
  330. },
  331. goPerson() {
  332. if (store.common.data.mockScenes === config.common.mockScenes.examine) {
  333. return
  334. }
  335. ay.goPage(config.pages.personCenter_index)
  336. },
  337. goPage(menu) {
  338. const maps = {
  339. 0() {
  340. methods.checkNopayfordriver(1)
  341. },
  342. 1() {
  343. ay.goPage(config.pages.order_index)
  344. },
  345. 2() {
  346. ay.goPage(config.pages.org_index)
  347. },
  348. 3() {
  349. ay.goPage(config.pages.cards_index)
  350. },
  351. }
  352. maps[menu.id]()
  353. },
  354. drawerOpen() {
  355. methods.getCityList()
  356. drawer.value.open()
  357. data.station.indexedListShow = true
  358. // 解决uni-indexed-list 组件滑动失效问题
  359. // 问题原因: 因为嵌套于uni-drawer内,造成uni-indexed-list的winOffsetY值获取有误
  360. // 解决方法:通过阅读组件源码发现uni-indexed-list在初始化时会设置winOffsetY,再给他设置正确的值。
  361. // 小程序于h5环境设置时机不同;
  362. // 组件内部:小程序仅首次渲染完毕会设置winOffsetY,h5环境每次打开组件都会重新设置winOffsetY
  363. // 通过监听$data.loaded的变化,重新设置winOffsetY为页面滚动距离,以及小程序环境-每次呈现组件后重新设置winOffsetY
  364. nextTick(() => {
  365. // 小程序环境-每次呈现组件后重新设置winOffsetY
  366. // #ifdef MP
  367. if (indexedList.value) {
  368. indexedList.value.$data.winOffsetY = staticData.scrollTop + topHeight.value
  369. }
  370. // #endif
  371. if (!staticData.indexedListWatcher) {
  372. staticData.indexedListWatcher = watch(
  373. () => indexedList.value?.$data.loaded,
  374. (nv) => {
  375. // 小程序环境仅首次呈现监听到, h5环境每次呈现都会监听到
  376. if (indexedList.value) {
  377. indexedList.value.$data.winOffsetY = staticData.scrollTop + topHeight.value
  378. }
  379. },
  380. {
  381. // deep: true,
  382. },
  383. )
  384. // 调用可释放监听
  385. // staticData.indexedListWatcher()
  386. }
  387. })
  388. },
  389. drawerChange(isopen) {},
  390. changeCity(args) {
  391. drawer.value.close()
  392. data.station.curCity = args.item.name
  393. uni.setStorageSync(staticData.cctkn, args.item.name)
  394. methods.getListApp()
  395. },
  396. goAccount() {
  397. ay.goPage(config.pages.account_index)
  398. },
  399. /** 初始化ws */
  400. initWS() {
  401. stompSocket
  402. .init(
  403. ay.getWebsocketUrl('websocket/sockjs'),
  404. // 传参
  405. {
  406. access_token: store.user.userInfo.token,
  407. identifier: store.user.userInfo.Identifier,
  408. },
  409. // ws断开回调
  410. () => {
  411. methods.initWS()
  412. },
  413. )
  414. .then((client) => {
  415. staticData.client = client
  416. // 订阅
  417. const subscription = client.subscribe(
  418. // 路径
  419. '/user/' + store.user.userInfo.user_id + '/msg',
  420. // 接收到的数据
  421. (res) => {
  422. const body = JSON.parse(res.body)
  423. if (body.type === 1) {
  424. ay.goPage(config.pages.order_prePay, { params: JSON.parse(body.content) })
  425. } else if (body.type === 0) {
  426. const content = JSON.parse(body.content)
  427. uni
  428. .showModal({
  429. title: content.data,
  430. message: content.message,
  431. })
  432. .then(() => {})
  433. }
  434. },
  435. )
  436. })
  437. },
  438. // 直接调用发送即可
  439. send() {
  440. staticData.client.send(
  441. // 路径
  442. '/user/' + store.user.userInfo.user_id + '/msg',
  443. {},
  444. // 发送文本
  445. JSON.stringify({ content: '1212' }),
  446. )
  447. },
  448. /** 检查未支付
  449. * type 0:仅检查 1:点击待支付订单 2:点击扫码
  450. * */
  451. async checkNopayfordriver(type: 0 | 1 | 2 = 0) {
  452. const nopayfordriver = await webapi.pay.find_unpayfordriver()
  453. // 存在 未支付(待支付、支付中、支付异常)
  454. if (nopayfordriver) {
  455. if (type === 1) {
  456. if (nopayfordriver.settleStatus === 1) {
  457. // 跳未支付
  458. ay.goPage(config.pages.order_prePay, { params: { orderId: nopayfordriver.orderId } })
  459. }
  460. }
  461. if (type === 2) {
  462. func.native
  463. .showModal({
  464. title: '温馨提示',
  465. content: '存在未支付完成订单',
  466. showCancel: true,
  467. })
  468. .then((res) => {
  469. if (res.confirm) {
  470. if (nopayfordriver.settleStatus === 1) {
  471. ay.goPage(config.pages.order_prePay, {
  472. params: { orderId: nopayfordriver.orderId },
  473. })
  474. } else {
  475. ay.goPage(config.pages.order_orderDetail, {
  476. params: { orderId: nopayfordriver.orderId },
  477. })
  478. }
  479. }
  480. })
  481. }
  482. return true
  483. } else {
  484. if (type === 1) {
  485. func.native.showToast('暂无待支付订单!')
  486. }
  487. return false
  488. }
  489. },
  490. async scanCode() {
  491. if (await methods.checkNopayfordriver(2)) {
  492. return
  493. }
  494. const ret: { gasstationId?: string; cashierId?: string } = await func.native.scan()
  495. if (!(ret.gasstationId && ret.cashierId)) {
  496. func.native.showToast('二维码无效')
  497. return
  498. }
  499. const user = await webapi.user.find_6({ userId: ret.cashierId })
  500. if (ret.gasstationId === user.user.orgId) {
  501. const price = await webapi.strategy.find_price({
  502. gasstationId: ret.gasstationId,
  503. driverId: user.user.userId,
  504. })
  505. if (
  506. ((price.qrcode === 0 || price.qrcode === 1) && ret.gasstationId !== ret.cashierId) || // 设置的加气站收款码
  507. (price.qrcode === 2 && ret.gasstationId === ret.cashierId) // 设置的收银员
  508. ) {
  509. func.native.showModal({
  510. title: '温馨提示',
  511. content:
  512. price.qrcode === 2
  513. ? '加气站收款码已禁用,请选择收银员收款码扫码。'
  514. : '收银员收款码已禁用,请选择加气站收款码扫码。',
  515. })
  516. } else {
  517. const gasJudge = await webapi.strategy.driver_gas_judge({
  518. driverId: user.user.userId,
  519. gasstationId: ret.gasstationId,
  520. })
  521. if (gasJudge === 1) {
  522. // 创建订单
  523. ay.goPage(config.pages.order_createOrder, { params: ret })
  524. } else if (gasJudge === 2) {
  525. func.native.showModal({
  526. title: '温馨提示',
  527. content: `该加气站未及时补充平台气源,已无法通过大象平台为您提供优质气源,给您带来的不便深感其歉意,如有疑问可以与加气站沟通,亦可拨打大象加气平台客服电话:"${store.common.data.phone}"`,
  528. })
  529. }
  530. }
  531. } else {
  532. func.native.showModal({
  533. title: '温馨提示',
  534. content: '当前收银员所属企业和二维码对应的企业不一致,请联系加气站管理员。',
  535. })
  536. }
  537. },
  538. /** 同意加入 */
  539. agree() {
  540. webapi.user.agree({ id: data.invite.driverWhiteList.id }).then((res) => {
  541. if (res) {
  542. func.native.showToast('加入成功,请重新登录').then(() => {})
  543. inputDialog.value.close()
  544. }
  545. })
  546. },
  547. /** 拒绝加入 */
  548. disagree() {
  549. webapi.user.disagree({ id: data.invite.driverWhiteList.id }).then((res) => {
  550. if (res) {
  551. func.native.showToast('已拒绝')
  552. inputDialog.value.close()
  553. }
  554. })
  555. },
  556. /** 获取邀请信息 */
  557. getInvite() {
  558. webapi.user
  559. .find_by_driver_mobile({ driverMobile: store.user.userInfo.mobile })
  560. .then((res) => {
  561. if (res.driverWhiteList && res.org) {
  562. data.invite = res
  563. inputDialog.value.open()
  564. }
  565. })
  566. },
  567. getCityList() {
  568. return webapi.strategy.city_list().then((res) => {
  569. res.unshift({ text: staticData.defCity, children: [{ text: staticData.defCity }] })
  570. data.station.cityList = res.map((m) => {
  571. return {
  572. letter: m.text,
  573. data: m.children.map((cm) => cm.text),
  574. }
  575. })
  576. })
  577. },
  578. async getListApp({
  579. cras = store.curPage.getDefAyContainerRefreshArgs(),
  580. activation = false,
  581. // checkScope = false,
  582. } = {}) {
  583. // 非激活 && 未授权
  584. if (!activation && !data.userLocation) {
  585. // 取消加载中效果
  586. ay.containerLoaded({
  587. reqState: enums.ReqState.cancel,
  588. })
  589. return
  590. }
  591. let location = staticData.location
  592. // 上拉不重新获取位置
  593. if (!cras.isAdd) {
  594. location = await func.native.getLocation(false)
  595. if (!location) return
  596. staticData.location = location
  597. }
  598. data.userLocation = true
  599. webapi.strategy
  600. .list_mini(
  601. {
  602. page: cras.page,
  603. size: cras.size,
  604. param: {
  605. city: data.station.curCity === staticData.defCity ? '' : data.station.curCity,
  606. longitude: location.longitude.toString(),
  607. latitude: location.latitude.toString(),
  608. },
  609. },
  610. // { showLoading: activation }, // || !cras.isAdd },
  611. )
  612. .then((res) => {
  613. if (cras.isAdd) {
  614. data.station.listApp.push(...res.records)
  615. } else {
  616. data.station.listApp = res.records
  617. }
  618. })
  619. },
  620. getQrcode() {
  621. if (data.hasnopayfordriver || store.webapi.strategy.get_user_qrcode.ing) {
  622. return
  623. }
  624. return webapi.strategy.get_user_qrcode({}, { minRTime: 1e3 }).then(async (res) => {
  625. data.qrcode.img = res
  626. data.qrcode.expire = false
  627. })
  628. },
  629. },
  630. {
  631. scanCode: { showLoading: true },
  632. },
  633. {
  634. ba(methodName) {
  635. // console.log(k)
  636. // 需要登录的功能
  637. if (staticData.IdentityMethods.includes(methodName)) {
  638. // 未登录
  639. if (!store.user.isLogined) {
  640. if (methodName === 'goPerson') {
  641. return true
  642. } else {
  643. func.native
  644. .showModal({
  645. title: '请先登录账号',
  646. confirmText: '同意',
  647. cancelText: '再看看',
  648. showCancel: true,
  649. })
  650. .then((res) => {
  651. if (res.confirm) {
  652. ay.goLogin()
  653. }
  654. })
  655. return false
  656. }
  657. }
  658. }
  659. },
  660. },
  661. )
  662. ay.entrance(
  663. async (args) => {
  664. // staticData.entranceArgs = args
  665. const init = async () => {
  666. webapi.strategy.get_driver_balance({}).then((res) => {
  667. data.accountInfo = {
  668. ...res,
  669. ...aop.request.AR.getAccountInfo(res),
  670. }
  671. })
  672. data.hasnopayfordriver = await methods.checkNopayfordriver()
  673. methods.getTruckInfo()
  674. }
  675. if (args.loadType === enums.LoadType.onLoad) {
  676. // data.title = store.curPage?.pageConfig?.title
  677. // #ifdef MP
  678. // 用户是否授权了获取地理位置
  679. await uni
  680. .getSetting()
  681. .then((res) => {
  682. if (res.authSetting['scope.userLocation']) {
  683. data.userLocation = true
  684. }
  685. })
  686. .catch()
  687. // #endif
  688. methods.getCityList()
  689. data.station.curCity = uni.getStorageSync(staticData.cctkn) || staticData.defCity
  690. methods.getListApp({ cras: args.cras })
  691. if (!store.user.isLogined) {
  692. // data.hasnopayfordriver = false
  693. // data.firstUnload = false
  694. return
  695. }
  696. methods.initWS()
  697. await init()
  698. // 无未支付订单
  699. if (!data.hasnopayfordriver) {
  700. await methods.getQrcode()
  701. }
  702. data.firstUnload = false
  703. // 小程序环境:时机过早会inputDialog.value为null
  704. // h5环境:当页面data内的值改变时,弹框会消失
  705. // 所有先放这里吧
  706. methods.getInvite()
  707. }
  708. if (args.loadType === enums.LoadType.refresh) {
  709. methods.getListApp({ cras: args.cras })
  710. // if (!args.cras.isAdd) {
  711. // init()
  712. // }
  713. }
  714. // if (args.loadType === enums.LoadType.onShow) {
  715. // init()
  716. // }
  717. },
  718. {
  719. addLoadTypes: [enums.LoadType.onShow],
  720. },
  721. )
  722. onPageScroll((res) => {
  723. staticData.scrollTop = res.scrollTop
  724. })
  725. </script>
  726. <style lang="scss" scoped>
  727. .center-item {
  728. min-height: 136rpx;
  729. }
  730. .top {
  731. padding-bottom: $p-spac;
  732. border-bottom: 1px dashed;
  733. .personal {
  734. width: 100rpx;
  735. height: 100rpx;
  736. margin-right: $p-spac;
  737. border-radius: $p-spac;
  738. }
  739. .mobile {
  740. margin-top: $p-spacd2;
  741. font-size: $s-fz;
  742. }
  743. }
  744. .qrcode {
  745. width: 400rpx;
  746. height: 400rpx;
  747. overflow: hidden;
  748. border-radius: $p-spacd2;
  749. .image {
  750. width: 480rpx;
  751. height: 480rpx;
  752. margin: -40rpx;
  753. }
  754. }
  755. .qrcode-text {
  756. height: $p-fz;
  757. }
  758. .truck {
  759. width: 152rpx;
  760. height: 116rpx;
  761. }
  762. #stationTop {
  763. padding: $p-spac 0;
  764. }
  765. .unit {
  766. margin: 0 $p-spacd2;
  767. }
  768. $bgc: rgba($p-color, 0.4);
  769. .cars {
  770. position: relative;
  771. overflow: hidden;
  772. &::after {
  773. position: absolute;
  774. top: 0;
  775. left: 0;
  776. width: 100%;
  777. height: 100%;
  778. content: '';
  779. background-image: linear-gradient($bgc, $bgc), url('@img/truck.svg');
  780. background-repeat: no-repeat;
  781. background-position: right;
  782. background-size: contain;
  783. opacity: 0.2;
  784. }
  785. }
  786. .menu {
  787. font-size: $s-fz;
  788. .icon {
  789. width: 80rpx;
  790. height: 80rpx;
  791. margin-bottom: $p-spacd2;
  792. border-radius: 50%;
  793. }
  794. }
  795. .list-app {
  796. margin-top: $p-spac;
  797. .title {
  798. font-size: $p-fz * 1.2;
  799. font-weight: bold;
  800. }
  801. }
  802. // 为了让左侧索引中文竖排
  803. ::v-deep .uni-indexed-list__menu-item {
  804. width: 20px;
  805. }
  806. ::v-deep .uni-popup__info {
  807. @apply: font-bold;
  808. font-size: $bs-fz;
  809. color: unset;
  810. }
  811. .scan {
  812. width: 50rpx;
  813. height: 50rpx;
  814. }
  815. </style>