index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <view class="container p-bottom" :style="appThemeStyle">
  3. <view class="container-br"></view>
  4. <view v-if="order.goodsList.length">
  5. <!-- 实物订单:选择配送方式 -->
  6. <block v-if="order.orderType == OrderTypeEnum.PHYSICAL.value">
  7. <!-- 配送方式选项卡 -->
  8. <view v-if="isShowTab" class="swiper-tab dis-flex flex-y-center flex-x-around">
  9. <view class="swiper-tab-item" :class="{on: curDelivery == DeliveryTypeEnum.EXPRESS.value}" @click="handleSwichDelivery(DeliveryTypeEnum.EXPRESS.value)">
  10. <text>快递配送</text>
  11. </view>
  12. </view>
  13. <!-- 快递配送:配送地址 -->
  14. <view v-if="curDelivery == DeliveryTypeEnum.EXPRESS.value" @click="onSelectAddress" class="flow-delivery">
  15. <view class="flow-delivery__detail dis-flex flex-y-center">
  16. <view class="detail-location dis-flex">
  17. <text class="iconfont icon-dingwei"></text>
  18. </view>
  19. <view class="detail-content flex-box">
  20. <block v-if="order.address">
  21. <view class="detail-content__title dis-flex">
  22. <text class="f-30">{{ order.address.name }}</text>
  23. <text class="detail-content__title-phone f-28">{{ order.address.phone }}</text>
  24. </view>
  25. <view class="address detail-content__describe">
  26. <text class="region" v-for="(region, idx) in order.address.region" :key="idx">{{ region }}</text>
  27. <text class="detail">{{ order.address.detail }}</text>
  28. </view>
  29. </block>
  30. <block v-else>
  31. <view class="detail-content__describe dis-flex">
  32. <text class="col-6">请选择配送地址</text>
  33. </view>
  34. </block>
  35. </view>
  36. <view class="detail-arrow dis-flex">
  37. <text class="iconfont icon-arrow-right"></text>
  38. </view>
  39. </view>
  40. </view>
  41. </block>
  42. <!-- 商品列表 -->
  43. <view class="checkout_list" v-for="(item, index) in order.goodsList" :key="index">
  44. <view class="flow-shopList dis-flex" data-index="index" @click="onTargetGoods(item.goods_id)">
  45. <!-- 商品图片 -->
  46. <view class="flow-list-left">
  47. <image mode="scaleToFill" :src="item?.productpic"></image>
  48. <text class="goods-props">时长:{{ item.productlimit }} 月</text> <br />
  49. <text class="goods-props">赠送:{{ item.productlimit1 }}</text
  50. ><br />
  51. <text class="goods-props">宽带:{{ item.productdkband }}</text
  52. ><br />
  53. <text class="goods-props">赠送时长:{{ item.productlimit }}</text>
  54. </view>
  55. <view class="flow-list-right flex-box">
  56. <!-- 商品名称 -->
  57. <text class="goods-name twoline-hide">{{ item.productname }}</text>
  58. <!-- 商品规格 -->
  59. <view class="goods-props clearfix">
  60. <view class="goods-props-item">
  61. <!-- <text class="group-name">时长:{{ item.productlimit }} 月</text><br />
  62. <text class="group-name">赠送:{{ item.productlimit1 }}</text
  63. ><br />
  64. <text class="group-name">宽带:{{ item.productdkband }}</text
  65. ><br />
  66. <text class="group-name">赠送时长:{{ item.productlimit }}</text
  67. ><br /> -->
  68. <text class="group-name">注:{{ item.productmemo }}</text>
  69. <!-- <text>火爆;</text> -->
  70. </view>
  71. </view>
  72. <!-- 商品数量和单价 -->
  73. <view class="flow-list-cont dis-flex flex-x-between flex-y-center">
  74. <text class="small">×1</text>
  75. <text class="flow-cont" style="text-decoration: line-through !important" :class="[item.is_user_grade ? 'price-delete' : '']">原价:¥{{ item.productprice }}</text>
  76. </view>
  77. <!-- 会员折扣价 -->
  78. <view class="grade-price">
  79. <text>折扣价:¥{{ item.productprice1 }}</text>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="flow-num-box b-f">
  85. <!-- <text>共{{ order.orderTotalNum }}件商品,合计:</text>
  86. <text class="flow-money col-m">¥{{ order.orderTotalPrice }}</text> -->
  87. <text>共 1 件商品</text>
  88. </view>
  89. <!-- 商品金额 -->
  90. <view class="flow-all-money b-f m-top20">
  91. <view class="flow-all-list dis-flex">
  92. <text class="flex-five">订单总金额:</text>
  93. <view class="flex-five t-r">
  94. <text class="col-m">¥{{ order.goodsList[0]?.productprice1 }}</text>
  95. </view>
  96. </view>
  97. <view class="flow-all-list dis-flex">
  98. <text class="flex-five">时长:</text>
  99. <view class="flex-five t-r">
  100. <text class="">{{ order.goodsList[0]?.productlimit }} {{order.goodsList[0]?.productlimittype}}</text>
  101. </view>
  102. </view>
  103. <view class="flow-all-list dis-flex">
  104. <text class="flex-five">宽带:</text>
  105. <view class="flex-five t-r">
  106. <text class="">{{ order.goodsList[0]?.productdkband }} M</text>
  107. </view>
  108. </view>
  109. <view class="flow-all-list dis-flex">
  110. <text class="flex-five">赠送时长:</text>
  111. <view class="flex-five t-r">
  112. <text class="">{{ order.goodsList[0]?.productlimit }} 小时</text>
  113. </view>
  114. </view>
  115. <view class="flow-all-list dis-flex">
  116. <text class="flex-five">类型:</text>
  117. <view class="flex-five t-r">
  118. <text v-if="mode === 'buyNow'" class="col-m">购入新账户</text>
  119. <text v-if="mode === 'buyXuyue'" class="col-m">账户续约</text>
  120. </view>
  121. </view>
  122. <!-- 优惠券 -->
  123. <!-- <view v-if="$checkModule('market-coupon')" class="flow-all-list dis-flex">
  124. <text class="flex-five">优惠券:</text>
  125. <view class="flex-five t-r">
  126. <view v-if="order.couponList.length > 0" @click="handleShowPopup()">
  127. <text class="col-m" v-if="order.couponId > 0">-¥{{ order.couponMoney }}</text>
  128. <text class="col-m" v-else>有{{ order.couponList.length }}张优惠券</text>
  129. <text class="right-arrow iconfont icon-arrow-right"></text>
  130. </view>
  131. <text v-else class="">无优惠券可用</text>
  132. </view>
  133. </view> -->
  134. <!-- 支付方式 -->
  135. <view class="flow-all-list">
  136. <text class="flex-five-center">请选择支付方式</text>
  137. <view class="flex-five t-r">
  138. <view class="payment-method">
  139. <view v-for="(item, index) in methodsPal" :key="index" class="pay-item dis-flex flex-x-between" @click="handleSelectPayType(index)">
  140. <view class="item-left dis-flex flex-y-center">
  141. <view class="item-left_icon" :class="`${item.paysortname}`">
  142. <text class="iconfont" :class="[item.paysortname == '支付宝' ? 'icon-alipay alipay' : 'icon-wechat-pay wechat']"></text>
  143. </view>
  144. <view class="item-left_text">
  145. <text>{{ item.paysortname }}</text>
  146. </view>
  147. </view>
  148. <view class="item-right col-m r_flex_center">
  149. <view class="gouxuan-box" :class="[curPaymentItem && curPaymentItem.paysortid == item.paysortid ? 'actvie-zf' : '']">
  150. <i-check-small
  151. theme="outline"
  152. size="16"
  153. fill="#fff"
  154. :strokeWidth="4"
  155. strokeLinejoin="bevel"
  156. strokeLinecap="square"
  157. v-if="curPaymentItem && curPaymentItem.paysortid == item.paysortid"
  158. />
  159. </view>
  160. </view>
  161. </view>
  162. <view class="payment-method" style="text-align: center; margin-top: 10px" v-if="methodsPal.length === 0"> 该企业没有支付方式 </view>
  163. </view>
  164. </view>
  165. </view>
  166. <!-- 积分抵扣 -->
  167. <view v-if="$checkModule('market-points') && order.isAllowPoints" class="points flow-all-list dis-flex flex-y-center">
  168. <view class="block-left flex-five" @click="handleShowPoints()">
  169. <text class="title">可用{{ setting.points_name }}抵扣:</text>
  170. <text class="iconfont icon-help"></text>
  171. </view>
  172. <view class="flex-five dis-flex flex-x-end flex-y-center">
  173. <text class="points-money col-m">-¥{{ order.pointsMoney }}</text>
  174. <u-switch v-model="isUsePoints" size="48" active-color="#07c160" @change="getOrderData()"></u-switch>
  175. </view>
  176. </view>
  177. <!-- 配送费用 -->
  178. <view v-if="false" class="dis-flex flow-all-list">
  179. <text class="flex-five">配送费用:</text>
  180. <view class="flex-five t-r">
  181. <view v-if="order.address">
  182. <text class="col-m" v-if="order.isIntraRegion">+¥{{ order.expressPrice }}</text>
  183. <text v-else>不在配送范围</text>
  184. </view>
  185. <view v-else>
  186. <text class="col-7">请先选择配送地址</text>
  187. </view>
  188. </view>
  189. </view>
  190. </view>
  191. <!-- 买家留言 -->
  192. <view class="flow-all-money b-f m-top20">
  193. <view class="ipt-wrapper flow-all-list">
  194. <input class="input" v-model="remark" placeholder="选填:买家留言(50字以内)" />
  195. </view>
  196. </view>
  197. <!-- 提交订单 -->
  198. <view class="flow-fixed-footer b-f m-top10">
  199. <view class="dis-flex chackout-box">
  200. <view class="chackout-left pl-12"
  201. >实付款:
  202. <text class="col-m">¥{{ order.goodsList[0]?.productprice1 }}</text>
  203. </view>
  204. <view class="chackout-right" @click="onSubmitOrder()">
  205. <view class="flow-btn f-32" :class="{disabled}">提交订单</view>
  206. </view>
  207. </view>
  208. </view>
  209. <!-- 积分说明弹窗 -->
  210. <u-modal v-model="showPoints" :title="`${setting.points_name}说明`">
  211. <scroll-view class="points-content" :scroll-y="true">
  212. <text>{{ setting.points_describe }}</text>
  213. </scroll-view>
  214. </u-modal>
  215. <!-- 优惠券弹出框 -->
  216. <u-popup v-model="showPopup" mode="bottom">
  217. <view class="popup__coupon">
  218. <view class="coupon__title f-30">选择优惠券</view>
  219. <!-- 优惠券列表 -->
  220. <view class="coupon-list">
  221. <scroll-view :scroll-y="true" style="height: 565rpx">
  222. <view class="coupon-item" v-for="(item, index) in order.couponList" :key="index">
  223. <view class="item-wrapper" :class="[item.is_apply ? 'color-' + CouponColors[`${index % CouponColors.length}`] : 'color-gray']">
  224. <view class="coupon-type">{{ CouponTypeEnum[item.coupon_type].name }}</view>
  225. <view class="tip dis-flex flex-dir-column flex-x-center">
  226. <view v-if="item.coupon_type == CouponTypeEnum.FULL_DISCOUNT.value">
  227. <text class="f-30">¥</text>
  228. <text class="money">{{ item.reduce_price }}</text>
  229. </view>
  230. <text class="money" v-if="item.coupon_type == CouponTypeEnum.DISCOUNT.value">{{ item.discount }}折</text>
  231. <text class="pay-line">满{{ item.min_price }}元可用</text>
  232. </view>
  233. <view class="split-line"></view>
  234. <view class="content dis-flex flex-dir-column flex-x-between">
  235. <view class="title">{{ item.name }}</view>
  236. <view class="bottom dis-flex flex-y-center">
  237. <view class="time flex-box">
  238. <block v-if="item.start_time === item.end_time">{{ item.start_time }} 当天有效</block>
  239. <block v-else>{{ item.start_time }}~{{ item.end_time }}</block>
  240. </view>
  241. </view>
  242. </view>
  243. </view>
  244. </view>
  245. </scroll-view>
  246. </view>
  247. <!-- 不使用优惠券 -->
  248. <view class="coupon__do_not dis-flex flex-y-center flex-x-center">
  249. <view class="control dis-flex flex-y-center flex-x-center" @click="handleNotUseCoupon()">
  250. <text class="f-26">不使用优惠券</text>
  251. </view>
  252. </view>
  253. </view>
  254. </u-popup>
  255. </view>
  256. <u-toast ref="uToast" />
  257. <div id="form" v-show="false" v-html="formDom"></div>
  258. </view>
  259. </template>
  260. <script>
  261. import * as Verify from '@/utils/verify'
  262. import * as CheckoutApi from '@/api/checkout'
  263. import * as AppApi from '@/api/app'
  264. import {CouponTypeEnum} from '@/common/enum/coupon'
  265. import {OrderTypeEnum, DeliveryTypeEnum} from '@/common/enum/order'
  266. import storage from '@/utils/storage'
  267. import {Alipay, Wechat} from '@/core/payment'
  268. const CouponColors = ['red', 'blue', 'violet', 'yellow']
  269. // 根据指定mode获取对应的api类
  270. const getCheckoutApi = (mode) => {
  271. const apiEnum = {
  272. buyNow: CheckoutApi,
  273. cart: CheckoutApi
  274. }
  275. return apiEnum[mode]
  276. }
  277. // 根据指定mode获取param
  278. const getModeParam = (mode, options) => {
  279. const param = {}
  280. console.log(options, 'options')
  281. // 结算模式: 立即购买
  282. if (mode === 'buyNow') {
  283. // param.goodsId = options.goodsId
  284. // param.goodsNum = options.goodsNum
  285. // param.goodsSkuId = options.goodsSkuId
  286. }
  287. // 结算模式: 购物车
  288. if (mode === 'cart') {
  289. // param.cartIds = options.cartIds
  290. }
  291. return param
  292. }
  293. export default {
  294. data() {
  295. return {
  296. // 枚举类
  297. OrderTypeEnum,
  298. DeliveryTypeEnum,
  299. CouponTypeEnum,
  300. // 当前页面参数
  301. options: {},
  302. // 配送方式
  303. isShowTab: false,
  304. DeliveryTypeEnum,
  305. curDelivery: null,
  306. // 优惠券颜色组
  307. CouponColors,
  308. // 选择的优惠券
  309. selectCouponId: 0,
  310. // 是否使用积分抵扣
  311. isUsePoints: false,
  312. // 买家留言
  313. remark: '',
  314. // 禁用submit按钮
  315. disabled: false,
  316. // 是否显示积分说明
  317. showPoints: false,
  318. // 是否显示优惠券弹窗
  319. showPopup: false,
  320. // 订单信息 (从后端api中获取)
  321. order: {
  322. // 商品列表
  323. goodsList: [],
  324. // 优惠券列表
  325. couponList: [],
  326. // 是否存在收货地址
  327. existAddress: false,
  328. // 默认收货地址
  329. address: null,
  330. // 是否存在收货地址
  331. existAddress: false,
  332. // 当前用户收货城市是否存在配送规则中
  333. isIntraRegion: true,
  334. // 是否存在错误
  335. hasError: false,
  336. // 错误信息
  337. errorMsg: ''
  338. },
  339. // 个人信息
  340. personal: {},
  341. // 商城设置
  342. setting: {},
  343. // 支付宝
  344. methodsPal: [],
  345. curPaymentItem: {},
  346. // 提交支付表单
  347. formDom: '',
  348. // 购买类型
  349. mode: ''
  350. }
  351. },
  352. /**
  353. * 生命周期函数--监听页面加载
  354. */
  355. async onLoad(options) {
  356. this.mode = options?.mode
  357. if (options?.goodsId) {
  358. let query = options
  359. this.queryData = await this.getProductData(query.goodsId)
  360. // 获取当前订单信息
  361. this.getOrderData()
  362. } else {
  363. this.$toast('没有商品')
  364. }
  365. },
  366. /**
  367. * 生命周期函数--监听页面的卸载
  368. */
  369. onUnload() {},
  370. /**
  371. * 生命周期函数--监听页面显示
  372. */
  373. onShow() {},
  374. methods: {
  375. // 选择支付方式
  376. handleSelectPayType(index) {
  377. this.curPaymentItem = this.methodsPal[index]
  378. },
  379. // 获取订单数据
  380. async getOrderData() {
  381. // 获取支付数据
  382. const params = {
  383. pageindex: 1,
  384. rows: 99,
  385. pagevalue: 288,
  386. 'paysortagentsqym.value': storage.get('wx_qym'),
  387. 'paysortsfky.value': 1
  388. }
  389. const {Data: res} = await AppApi.getPalList(params)
  390. this.methodsPal = res.Data
  391. this.handleSelectPayType(0)
  392. this.initData()
  393. // const app = this
  394. // const {
  395. // options: {mode}
  396. // } = app
  397. // // 请求的参数
  398. // const params = app.getRequestParam()
  399. // // 请求api
  400. // getCheckoutApi(mode)
  401. // .order(mode, params)
  402. // .then((result) => app.initData(result.data))
  403. // .catch((err) => err)
  404. },
  405. async getProductData(id) {
  406. const params = {
  407. pageindex: 1,
  408. rows: 9,
  409. 'productid.value': id
  410. }
  411. const {Data: res} = await AppApi.getShopList(params)
  412. return res.Data
  413. },
  414. // 初始化数据
  415. initData(setting, personal) {
  416. const app = this
  417. const order = {
  418. // 优惠劵
  419. couponList: [],
  420. // 地址
  421. address: {},
  422. // 配送方式
  423. delivery: 10,
  424. // 商品
  425. goodsList: this.queryData
  426. }
  427. app.order = order
  428. app.personal = {
  429. address_id: 15328,
  430. balance: '0.00',
  431. points: 0,
  432. user_id: 19016
  433. }
  434. app.setting = {
  435. deliveryType: [10],
  436. points_describe: '积分不可兑现、不可转让',
  437. points_name: '积分'
  438. }
  439. // 显示错误信息
  440. if (order.hasError) {
  441. app.showToast(order.errorMsg, 3000)
  442. }
  443. // 当前选择的配送方式
  444. app.curDelivery = order.delivery
  445. // 如果只有一种配送方式则不显示选项卡
  446. app.isShowTab = app.setting.deliveryType.length > 1
  447. console.log(order, '订单数据')
  448. },
  449. // 获取api请求的参数
  450. getRequestParam() {
  451. const app = this
  452. const {options} = app
  453. // 结算模式的固定参数
  454. const modeParam = getModeParam(options.mode, options)
  455. // 订单结算参数(用户选择)
  456. const orderParam = {
  457. delivery: app.curDelivery || 0,
  458. couponId: app.selectCouponId || 0,
  459. isUsePoints: app.isUsePoints ? 1 : 0
  460. }
  461. return {...orderParam, ...modeParam}
  462. },
  463. // 切换配送方式
  464. handleSwichDelivery(key) {
  465. this.curDelivery = key
  466. this.getOrderData()
  467. },
  468. // 显示积分说明
  469. handleShowPoints() {
  470. this.showPoints = true
  471. },
  472. // 显示优惠券弹窗
  473. handleShowPopup() {
  474. this.showPopup = true
  475. },
  476. // 选择优惠券
  477. handleSelectCoupon(index) {
  478. const app = this
  479. const {couponList} = app.order
  480. // 当前选择的优惠券
  481. const couponItem = couponList[index]
  482. // 判断是否在适用范围
  483. if (!couponItem.is_apply) {
  484. app.showToast(couponItem.not_apply_info)
  485. return
  486. }
  487. // 记录选中的优惠券id
  488. app.selectCouponId = couponItem.user_coupon_id
  489. // 重新获取订单信息
  490. app.getOrderData()
  491. // 隐藏优惠券弹层
  492. app.showPopup = false
  493. },
  494. // 不使用优惠券
  495. handleNotUseCoupon() {
  496. const app = this
  497. app.selectCouponId = 0
  498. // 重新获取订单信息
  499. app.getOrderData()
  500. // 隐藏优惠券弹层
  501. app.showPopup = false
  502. },
  503. // 快递配送:选择收货地址
  504. onSelectAddress() {
  505. this.$navTo('pages/address/index', {from: 'checkout'})
  506. },
  507. // 跳转到商品详情页
  508. onTargetGoods(goodsId) {
  509. this.$navTo('pages/goods/detail', {goodsId})
  510. },
  511. // 提交支付订单
  512. async onSubmitOrder() {
  513. const app = this
  514. if (app.disabled) {
  515. return false
  516. }
  517. // 支付方式
  518. if (!app.curPaymentItem.paysortname) {
  519. app.$toast('您还没有选择支付方式')
  520. return false
  521. }
  522. // 按钮禁用
  523. app.disabled = true
  524. const pram = {
  525. // 客户id
  526. customerid: storage.get('wx_userid'),
  527. // wx_openid
  528. openid: storage.get('wx_openid'),
  529. // 支付方式
  530. paysortid: app.curPaymentItem.paysortid,
  531. // 用户id
  532. yhinfoid: storage.get('wx_yhinfo')[0] ? storage.get('wx_yhinfo')[0].yhinfoid : '',
  533. // 资费类型
  534. productid: app.order.goodsList[0].productid
  535. // 金额
  536. // price: Number(this.order.goodsList[0].productprice1).toFixed(2)
  537. }
  538. let res = {}
  539. switch (app.mode) {
  540. // 购买新账户
  541. case 'buyNow':
  542. res = await AppApi.plFomr3(pram).finally(() => (app.disabled = false))
  543. break
  544. // 续约
  545. case 'buyXuyue':
  546. res = await AppApi.plXufei(pram).finally(() => (app.disabled = false))
  547. break
  548. default:
  549. break
  550. }
  551. app.disabled = true
  552. app.$toast('发起' + app.curPaymentItem.paysortname + '支付...')
  553. if (app.curPaymentItem.paysortname == '支付宝') {
  554. // 发起支付宝支付
  555. this.formDom = res.Data
  556. // app.$toast('提交支付宝中...')
  557. if (this.formDom) {
  558. setTimeout(() => {
  559. document.forms['alipaysubmit'].submit()
  560. app.disabled = false
  561. }, 500)
  562. setTimeout(() => {
  563. app.$navTo('pages/user/index')
  564. }, 1000)
  565. }
  566. } else if (app.curPaymentItem.paysortname == '微信') {
  567. // 发起微信支付
  568. this.formDom = res.Data
  569. const wechat = res
  570. // app.$toast('提交微信中...')
  571. WeixinJSBridge.invoke(
  572. 'getBrandWCPayRequest',
  573. {
  574. appId: wechat.Data.appId, //公众号ID,由商户传入
  575. timeStamp: wechat.Data.timeStamp, //时间戳,自1970年以来的秒数
  576. nonceStr: wechat.Data.nonceStr, //随机串
  577. package: wechat.Data.package,
  578. signType: wechat.Data.signType, //微信签名方式:
  579. paySign: wechat.Data.paySign
  580. },
  581. function (res) {
  582. // 支付成功
  583. if (res.err_msg == 'get_brand_wcpay_request:ok') {
  584. // 使用以上方式判断前端返回,微信团队郑重提示:
  585. app.$toast('支付成功')
  586. app.$navTo('pages/user/index')
  587. }
  588. // 支付过程中用户取消
  589. if (res.err_msg == 'get_brand_wcpay_request:cancel') {
  590. app.$toast('支付取消')
  591. app.disabled = false
  592. }
  593. // 支付失败
  594. if (res.err_msg == 'get_brand_wcpay_request:fail') {
  595. app.$toast('支付失败')
  596. app.disabled = false
  597. }
  598. }
  599. )
  600. }
  601. },
  602. // 跳转到我的订单(等待1秒)
  603. navToMyOrder() {
  604. setTimeout(() => {
  605. this.$navTo('pages/order/index', {}, 'redirectTo')
  606. }, 1000)
  607. },
  608. // 表单提交的数据
  609. getFormData() {
  610. const app = this
  611. const {options} = app
  612. // 表单数据
  613. const form = {
  614. delivery: app.curDelivery,
  615. couponId: app.selectCouponId || 0,
  616. isUsePoints: app.isUsePoints ? 1 : 0,
  617. remark: app.remark || ''
  618. }
  619. // 获取不同模式的参数
  620. const modeParam = getModeParam(options.mode, options)
  621. return {...form, ...modeParam}
  622. },
  623. // 表单验证
  624. onVerifyFrom() {
  625. const app = this
  626. if (app.hasError) {
  627. app.showToast(app.errorMsg, 3000)
  628. return false
  629. }
  630. return true
  631. },
  632. // 显示toast信息
  633. showToast(title, duration = 2000) {
  634. this.$refs.uToast.show({title, duration})
  635. }
  636. }
  637. }
  638. </script>
  639. <style lang="scss" scoped>
  640. @import './style.scss';
  641. </style>