Commit ecde406930baaa00e4f75e72058300eb19eeee89

Authored by 范牧
1 parent 8bd42a7f24
Exists in master

部分bug修改

src/pages/confirmOrder/confirmOrder.vue
... ... @@ -23,25 +23,34 @@
23 23 @tap="toaddAddress"
24 24 class="list order-user"
25 25 >
26   - <view class="order-user-head" v-if="addressInfo != false">
  26 + <view
  27 + class="order-user-head"
  28 + v-if="addressInfo != false"
  29 + >
27 30 <view class="name">
28 31 <view
29 32 v-if="addressInfo.default === '1'"
30 33 class="default"
31   - >
32   - <text>默认</text>
33   - </view>
34   - {{addressInfo.name}}
  34 + >
  35 + <text>默认</text>
  36 + </view>
  37 + {{addressInfo.name}}
35 38 </view>
36 39 <text class="mobile">{{addressInfo.mobile}}</text>
37 40 </view>
38   - <view class="order-user-body" v-if="addressInfo != false">
  41 + <view
  42 + class="order-user-body"
  43 + v-if="addressInfo != false"
  44 + >
39 45 <image src="../../static/myorder-paying-location.png"></image>
40 46 <text class="address">{{addressInfo.address}}\n{{addressInfo.add_detail}}</text>
41   - </view>
42   - <view class="order-user-body" v-if="addressInfo == false">
43   - <text class="address">点击添加地址</text>
44   - </view>
  47 + </view>
  48 + <view
  49 + class="order-user-body"
  50 + v-if="addressInfo == false"
  51 + >
  52 + <text class="address">点击添加地址</text>
  53 + </view>
45 54 <image
46 55 class="arrow"
47 56 src="../../static/right.png"
... ... @@ -262,34 +271,34 @@ export default {
262 271 addressInfo: {
263 272 address: '',
264 273 },
265   - isCart: Boolean,
  274 + isCart: Boolean,
266 275 // isAnonymous:
267   - checkedCartLst: [],
  276 + checkedCartLst: [],
268 277 }
269 278 },
270 279 onShow(addressId) {
271   - // console.log('+-+-*-*-+-+',addressId)
  280 + // console.log('+-+-*-*-+-+',addressId)
272 281 if (addressId) {
273   - store
274   - .dispatch('address/details', {
275   - add_id: addressId,
276   - })
277   - .then(({ code, data }) => {
278   - if (code === 1) {
279   - // console.log('code', code, data)
280   - this.showAddress = true
281   - this.addressInfo = data
282   - }
283   - })
  282 + store
  283 + .dispatch('address/details', {
  284 + add_id: addressId,
  285 + })
  286 + .then(({ code, data }) => {
  287 + if (code === 1) {
  288 + // console.log('code', code, data)
  289 + this.showAddress = true
  290 + this.addressInfo = data
  291 + }
  292 + })
284 293 }
285 294 },
286 295 onLoad({ pid, addressId, isCart, count, name }) {
287   - if (isCart == 'false') {
  296 + if (isCart == 'false') {
288 297 this.pid = pid
289 298 // store.dispatch('read/fetch', {
290   - // pid,
  299 + // pid,
291 300 // })
292   - }
  301 + }
293 302 this.count = count
294 303 this.name = name
295 304 this.isCart = isCart
... ... @@ -307,36 +316,36 @@ export default {
307 316 if (code === 1) {
308 317 // console.log('code', code, data)
309 318 this.showAddress = true
310   - this.addressInfo = data
  319 + this.addressInfo = data
311 320 }
312 321 })
313 322 } else {
314 323 store.dispatch('address/default').then(({ code, data }) => {
315   - this.showAddress = true
316   - this.addressInfo = data
317   - console.log("this.addressInfo", this.addressInfo)
  324 + this.showAddress = true
  325 + this.addressInfo = data
  326 + console.log('this.addressInfo', this.addressInfo)
318 327 })
319 328 }
320 329 },
321 330 computed: {
322   - totalPrice() {
323   - if (this.isCart == 'true') {
324   - let total = 0
325   - this.$store.state.cart.checkedCartLst.map(item => {
326   - total += item.nowPrice * item.num
327   - })
328   - return total
329   - } else {
330   - return this.buyItem.real_price * this.count
331   - }
332   - },
333   - buyItem() {
334   - return this.$store.state.cart.buyItem
335   - },
336   - // checkedCartLst(){
337   - // console.log('checkedCartLst',this.$store.state.cart.checkedCartLst)
338   - // return this.$store.state.cart.checkedCartLst
339   - // },
  331 + totalPrice() {
  332 + if (this.isCart == 'true') {
  333 + let total = 0
  334 + this.$store.state.cart.checkedCartLst.map(item => {
  335 + total += item.nowPrice * item.num
  336 + })
  337 + return total
  338 + } else {
  339 + return this.buyItem.real_price * this.count
  340 + }
  341 + },
  342 + buyItem() {
  343 + return this.$store.state.cart.buyItem
  344 + },
  345 + // checkedCartLst(){
  346 + // console.log('checkedCartLst',this.$store.state.cart.checkedCartLst)
  347 + // return this.$store.state.cart.checkedCartLst
  348 + // },
340 349 goodInfo() {
341 350 // console.log('state', this.$store.state.read.goodInfo)
342 351 return this.$store.state.read.goodInfo
... ... @@ -354,17 +363,17 @@ export default {
354 363 methods: {
355 364 counter(isadd, index) {
356 365 if (isadd) {
357   - if (this.isCart == 'true') {
358   - this.checkedCartLst[index].num++
359   - } else {
  366 + if (this.isCart == 'true') {
  367 + this.checkedCartLst[index].num++
  368 + } else {
360 369 this.count++
361   - }
  370 + }
362 371 } else {
363   - if (this.isCart == 'true') {
364   - this.checkedCartLst[index].num <= 1 ? (this.disabled = true) : this.checkedCartLst[index].num--
365   - } else {
366   - this.count <= 1 ? (this.disabled = true) : this.count--
367   - }
  372 + if (this.isCart == 'true') {
  373 + this.checkedCartLst[index].num <= 1 ? (this.disabled = true) : this.checkedCartLst[index].num--
  374 + } else {
  375 + this.count <= 1 ? (this.disabled = true) : this.count--
  376 + }
368 377 }
369 378 },
370 379 // 跳转添加地址页面
... ... @@ -379,63 +388,63 @@ export default {
379 388 })
380 389 },
381 390 // 下单
382   - orderBuild() {
383   - if(!this.addressInfo){
384   - uni.showLoading({
385   - title: '请先添加地址',
386   - })
387   - return
388   - }
  391 + orderBuild() {
  392 + if (!this.addressInfo) {
  393 + uni.showLoading({
  394 + title: '请先添加地址',
  395 + })
  396 + return
  397 + }
389 398 uni.showLoading({
390 399 title: '支付中',
391   - })
392   - if (this.isCart === 'true') {
393   - const checkedGoods = []
394   - const sk_id_arr = []
395   - this.checkedCartLst.map(item => {
396   - checkedGoods.push(item.cart_id)
397   - sk_id_arr.push(item.sk_id)
398   - })
399   - store.dispatch('order/build', {
  400 + })
  401 + if (this.isCart === 'true') {
  402 + const checkedGoods = []
  403 + const sk_id_arr = []
  404 + this.checkedCartLst.map(item => {
  405 + checkedGoods.push(item.cart_id)
  406 + sk_id_arr.push(item.sk_id)
  407 + })
  408 + store.dispatch('order/build', {
400 409 uid: this.$store.state.user.userInfo.uid,
401   - address: JSON.stringify(this.addressInfo),
  410 + address: JSON.stringify(this.addressInfo),
402 411 checkedGoods: checkedGoods,
403   - sk_id_arr: sk_id_arr,
404   - totalPrice: this.totalPrice,
405   - }).then((res) => {
406   - this.pay(res)
407   - })
408   - }
409   - if (this.isCart === 'false') {
410   - const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param
411   - store.dispatch('order/buyNow', {
412   - pid: skId.pid,
413   - sk_id: skId.sk_id,
414   - number: this.count,
415   - mp_id: mpId,
416   - address: JSON.stringify(this.addressInfo),
417   - totalPrice: this.totalPrice,
418   - liuyan: this.note,
419   - dir: 1,
420   - }).then((res) => {
421   - this.pay(res)
422   - })
423   - }
  412 + sk_id_arr: sk_id_arr,
  413 + totalPrice: this.totalPrice * 100,
  414 + }).then((res) => {
  415 + this.pay(res)
  416 + })
  417 + }
  418 + if (this.isCart === 'false') {
  419 + const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param
  420 + store.dispatch('order/buyNow', {
  421 + pid: skId.pid,
  422 + sk_id: skId.sk_id,
  423 + number: this.count,
  424 + mp_id: mpId,
  425 + address: JSON.stringify(this.addressInfo),
  426 + totalPrice: this.totalPrice * 100,
  427 + liuyan: this.note,
  428 + dir: 1,
  429 + }).then((res) => {
  430 + this.pay(res)
  431 + })
  432 + }
424 433 },
425 434 // 支付
426 435 pay(res) {
427 436 console.log('pay', res)
428   - const { data, exKeyName: keyName } = res
  437 + const { data, exKeyName: keyName } = res
429 438 const uid = uni.getStorageSync('uid')
430 439 const timeStamp = new Date().getTime().toString()
431   - const nonceStr = 'asfafasfasfasfasf'
  440 + const nonceStr = 'asfafasfasfasfasf'
432 441 // 支付参数
433 442 const fieldSet = {
434 443 openid: this.$store.state.user.userInfo.openid,
435 444 uid: this.$store.state.user.userInfo.uid,
436 445 shopid: 0,
437 446 payCate: 2020,
438   - payMoney: this.totalPrice,
  447 + payMoney: this.totalPrice * 100,
439 448 payWoodId: `fcdj-${uid}-${keyName}`,
440 449 payWoodDesc: '在【非常戴镜】的微信付款凭证',
441 450 nonceStr,
... ... @@ -443,13 +452,13 @@ export default {
443 452 app_uid: 2020,
444 453 timeStamp,
445 454 keyname: keyName,
446   - billInfo: JSON.stringify({
447   - address:this.addressInfo,
448   - list:data,
449   - keyname: keyName
450   - }),
451   - }
452   - console.log("fieldSet", fieldSet)
  455 + billInfo: JSON.stringify({
  456 + address: this.addressInfo,
  457 + list: data,
  458 + keyname: keyName,
  459 + }),
  460 + }
  461 + console.log('fieldSet', fieldSet)
453 462 // 请求后台支付接口
454 463 store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
455 464 if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
... ... @@ -601,9 +610,9 @@ export default {
601 610 .price {
602 611 color: #ff6b4a;
603 612 font-size: 28rpx;
604   - text{
605   - margin-left: 10rpx;
606   - }
  613 + text {
  614 + margin-left: 10rpx;
  615 + }
607 616 }
608 617 .originCost {
609 618 text-decoration: line-through;
... ...
src/pages/myOrder/components/OrderCard.vue
... ... @@ -41,12 +41,12 @@
41 41 <view class="orderName">{{orderInfo.p_name}}</view>
42 42 <view class="orderDescrib">{{orderInfo.p_name}}</view>
43 43 <view class="infoText-bottom">
44   - <view class="markPrice">{{orderInfo.nowPrice}}</view>
  44 + <view class="markPrice">¥{{orderInfo.nowPrice}}</view>
45 45 <view class="buy-num">X {{orderInfo.num}}</view>
46 46 </view>
47 47 </view>
48 48 </view>
49   - <view class="payPrice">实付:<text class="priceNum">{{order.total_fee}}</text> </view>
  49 + <view class="payPrice">实付:<text class="priceNum">¥{{order.total_fee}}</text> </view>
50 50 <!-- 0待付款 1 已付款 待收货 2 已收货待评价 3 已评价 -->
51 51 <view
52 52 class="btns"
... ... @@ -110,8 +110,8 @@
110 110 <view
111 111 class="orderCardInfo"
112 112 @click="toOrderInfo(status,order.pay_id)"
113   - v-for="(orderInfo) in orderInfoList"
114   - :key="orderInfo"
  113 + v-for="(orderInfo, index) in orderInfoList"
  114 + :key="index"
115 115 >
116 116 <image
117 117 :src="orderInfo.imgUrl"
... ... @@ -121,12 +121,12 @@
121 121 <view class="orderName">{{orderInfo.p_name}}</view>
122 122 <view class="orderDescrib">{{orderInfo.p_name}}</view>
123 123 <view class="infoText-bottom">
124   - <view class="markPrice">{{orderInfo.nowPrice}}</view>
  124 + <view class="markPrice">¥{{orderInfo.nowPrice}}</view>
125 125 <view class="buy-num">X {{orderInfo.num}}</view>
126 126 </view>
127 127 </view>
128 128 </view>
129   - <view class="payPrice">实付:<text class="priceNum">{{order.total_fee}}</text> </view>
  129 + <view class="payPrice">实付:<text class="priceNum">¥{{order.total_fee}}</text> </view>
130 130 <view
131 131 class="btns"
132 132 v-if="status == '0'"
... ... @@ -189,8 +189,7 @@ export default {
189 189 return this.order.status
190 190 },
191 191 orderInfoList() {
192   - const orderInfoList = this.order.order_info
193   - return Array.isArray(orderInfoList) ? orderInfoList : orderInfoList.data
  192 + return this.order.order_info.list
194 193 },
195 194 },
196 195 methods: {
... ... @@ -291,42 +290,33 @@ export default {
291 290 },
292 291  
293 292 async cancleOrder(e) {
294   - const openid = uni.getStorageSync('openid')
295   - const uid = this.order.uid
296   - // 先从订单详情中拿到keyname
297   - await store.dispatch('orderRead/getOrderInfo', {
298   - pay_id: this.order.pay_id,
299   - uid: uid,
300   - openid: openid,
301   - }).then((res) => {
302   - const keyname = res.order_info.keyname
303   - uni.showModal({
304   - title: '提示',
305   - content: '现在取消,订单不可恢复哦,确认取消吗?',
306   - success: function(res) {
307   - if (res.confirm) {
308   - store.dispatch('cancelOrder/cancel', {
309   - keyname: keyname,
310   - uid: uid,
311   - openid: openid,
312   - }).then((res) => {
313   - console.log(res)
314   - if (res.code == 1) {
315   - store.dispatch('myOrder/getList', {
316   - way: '',
317   - })
318   - } else {
319   - uni.showToast({
320   - title: '取消失败,服务器错误!',
321   - icon: 'none',
322   - })
323   - }
324   - })
325   - } else if (res.cancel) {
326   - console.log('用户点击取消')
327   - }
328   - },
329   - })
  293 + const { keyname } = this.order.order_info
  294 + console.log('keyname', keyname)
  295 +
  296 + uni.showModal({
  297 + title: '提示',
  298 + content: '现在取消,订单不可恢复哦,确认取消吗?',
  299 + success: function(res) {
  300 + if (res.confirm) {
  301 + store.dispatch('cancelOrder/cancel', {
  302 + keyname: keyname,
  303 + }).then((res) => {
  304 + console.log(res)
  305 + if (res.code === 1) {
  306 + store.dispatch('myOrder/getList', {
  307 + way: '',
  308 + })
  309 + } else {
  310 + uni.showToast({
  311 + title: '取消失败,服务器错误!',
  312 + icon: 'none',
  313 + })
  314 + }
  315 + })
  316 + } else if (res.cancel) {
  317 + console.log('用户点击取消')
  318 + }
  319 + },
330 320 })
331 321 },
332 322 toDetail(pid) {
... ...
src/pages/myOrder/myOrder.vue
... ... @@ -27,7 +27,7 @@
27 27 <OrderCard
28 28 :order="order"
29 29 :current="current"
30   - v-if="order.order_info !== null"
  30 + v-if="order.order_info !== null"
31 31 ></OrderCard>
32 32 </view>
33 33 </view>
... ... @@ -35,57 +35,57 @@
35 35 </view>
36 36 </template>
37 37 <script>
38   -import OrderCard from "./components/OrderCard.vue";
39   -import store from "@/store";
  38 +import OrderCard from './components/OrderCard.vue'
  39 +import store from '@/store'
40 40  
41 41 export default {
42 42 components: {
43   - OrderCard: OrderCard
  43 + OrderCard: OrderCard,
44 44 },
45 45 data() {
46 46 return {
47 47 // 顶部筛选项
48 48 screenItems: [
49   - { current: "10", text: "全部" },
50   - { current: "0", text: "待付款" },
51   - { current: "1", text: "待收货" },
52   - { current: "2", text: "已完成" }
  49 + { current: '10', text: '全部' },
  50 + { current: '0', text: '待付款' },
  51 + { current: '1', text: '待收货' },
  52 + { current: '2', text: '已完成' },
53 53 // {current:"3",text:'已评价'},
54 54 // {current:"4",text:'退款'},
55 55 ],
56 56 // 当前所在item 默认10-->全部
57   - current: "10"
58   - };
  57 + current: '10',
  58 + }
59 59 },
60 60  
61   -onShow() {
62   - store.dispatch("myOrder/getList", {
63   - way: ""
64   - });
65   -},
  61 + onShow() {
  62 + store.dispatch('myOrder/getList', {
  63 + way: '',
  64 + })
  65 + },
66 66 onLoad: function(option) {
67 67 // 获取订单列表
68 68 // store.dispatch("myOrder/getList", {
69 69 // way: ""
70 70 // });
71 71 // 从user过来传的status,给current,以显示对应item
72   - this.current = option.status;
  72 + this.current = option.status
73 73 },
74 74 computed: {
75 75 orderList() {
76   - console.log('orderList', this.$store.state.myOrder.orderList);
77   - return this.$store.state.myOrder.orderList;
78   - }
  76 + console.log('orderList', this.$store.state.myOrder.orderList)
  77 + return this.$store.state.myOrder.orderList
  78 + },
79 79 },
80 80 methods: {
81 81 // tab点击事件
82 82 onClickItem(e) {
83 83 if (this.current !== e) {
84   - this.current = e;
  84 + this.current = e
85 85 }
86   - }
87   - }
88   -};
  86 + },
  87 + },
  88 +}
89 89 </script>
90 90  
91 91 <style lang="scss">
... ...
src/pages/myOrderPaying/myOrderPaying.vue
1 1 <!-- 订单待付款 待收货 -->
2 2 <template>
3   - <view class="content">
4   - <view
5   - class="headerBanner"
6   - v-if="status == '2'||'3'"
7   - >
8   - <view class="bannerLeft">
9   - <view class="T1">订单已完成</view>
10   - </view>
11   - <image
12   - src="../../static/car.png"
13   - mode="aspectFill"
14   - ></image>
15   - </view>
16   - <!-- 待付款 -->
17   - <view class="order-time" v-if="status == '0'" >
18   - <text>请在</text>
19   - <uni-countdown
20   - color="#EC5D3B"
21   - splitor-color="#EC5D3B"
22   - :show-day="false"
23   - :hour="0"
24   - :second="getLeftTime"
25   - @timeup="timeup" >
26   - </uni-countdown>
27   -
28   - <text>内完成付款</text>
29   - </view>
30   -
31   - <view class="headerBanner" v-if="status == '1'">
  3 + <view class="content">
  4 + <view
  5 + class="headerBanner"
  6 + v-if="status == '2'||'3'"
  7 + >
  8 + <view class="bannerLeft">
  9 + <view class="T1">订单已完成</view>
  10 + </view>
  11 + <image
  12 + src="../../static/car.png"
  13 + mode="aspectFill"
  14 + ></image>
  15 + </view>
  16 + <!-- 待付款 -->
  17 + <view
  18 + class="order-time"
  19 + v-if="status == '0'"
  20 + >
  21 + <text>请在</text>
  22 + <uni-countdown
  23 + color="#EC5D3B"
  24 + splitor-color="#EC5D3B"
  25 + :show-day="false"
  26 + :hour="0"
  27 + :second="getLeftTime"
  28 + @timeup="timeup"
  29 + >
  30 + </uni-countdown>
  31 +
  32 + <text>内完成付款</text>
  33 + </view>
  34 +
  35 + <view
  36 + class="headerBanner"
  37 + v-if="status == '1'"
  38 + >
32 39 <view class="bannerLeft">
33 40 <view class="T1">卖家已发货</view>
34 41 <!-- <view class="T2">还剩 确认收货</view> -->
... ... @@ -37,9 +44,8 @@
37 44 src="../../static/car.png"
38 45 mode="aspectFill"
39 46 ></image>
40   - </view>
41   -
42   -
  47 + </view>
  48 +
43 49 <view class="order">
44 50 <view class="order-user">
45 51 <view class="order-user-head">
... ... @@ -71,7 +77,7 @@
71 77 <!-- <view class="arrow"></view> -->
72 78 </view>
73 79 <view class="infoText-bottom">
74   - <view class="markPrice">{{orderInfoListItem.nowPrice}}</view>
  80 + <view class="markPrice">{{Number(orderInfoListItem.nowPrice)/100}}</view>
75 81 <view class="buy-num">X {{orderInfoListItem.num}}</view>
76 82 </view>
77 83 </view>
... ... @@ -89,14 +95,13 @@
89 95 </text>
90 96 <text class="order-info-price">
91 97 <text class="p1">实付</text>
92   - <text class="p2">¥{{orderInfo.order_info.total_fee}}</text>
93   -
  98 + <text class="p2">¥{{Number(totalPrice)/100}}</text>
94 99 </text>
95 100 <text class="order-info-num">
96 101 <text>订单号:{{payId}}</text>
97 102 </text>
98 103 <text class="order-info-time">
99   - <text>下单时间:{{orderInfo.order_info?orderInfo.order_info.pay_time:'' | timerChange}}</text>
  104 + <text>下单时间:{{orderInfo.pay_time}}</text>
100 105 </text>
101 106 <view class="order-info-hr"></view>
102 107 <view class="order-info-contact">
... ... @@ -128,42 +133,41 @@
128 133 class="b2"
129 134 @click="confirmOrder"
130 135 >确认收货</button>
131   - </view>
132   - <view
133   - class="order-confim"
134   - v-if="status == '2'"
135   - >
136   - <button
137   - class="b2"
138   - @click="toDetail"
139   - >再次购买</button>
140   - </view>
141   -
  136 + </view>
  137 + <view
  138 + class="order-confim"
  139 + v-if="status == '2'"
  140 + >
  141 + <button
  142 + class="b2"
  143 + @click="toDetail"
  144 + >再次购买</button>
  145 + </view>
  146 +
142 147 </view>
143 148 </template>
144 149  
145 150 <script>
146   -import store from "@/store";
  151 +import store from '@/store'
147 152 import MD5Util from '../../utils/md5'
148   -import UniCountdown from "../../components/UniCountdown/UniCountdown.vue";
  153 +import UniCountdown from '../../components/UniCountdown/UniCountdown.vue'
149 154 export default {
150 155 components: {
151   - UniCountdown
152   - },
  156 + UniCountdown,
  157 + },
153 158 data() {
154 159 return {
155   - payId: "",
156   - payTime: "",
157   - status: "", // status 0 待付款 1 已发货
158   - uid: "",
159   - openid: "",
  160 + payId: '',
  161 + payTime: '',
  162 + status: '', // status 0 待付款 1 已发货
  163 + uid: '',
  164 + openid: '',
160 165 lefttime: 0,
161   - isPay: 0,
162   - orderInfo:{},
163   - totalPrice:0,
164   - };
  166 + isPay: 0,
  167 + totalPrice: 0,
  168 + }
165 169 },
166   - onLoad:async function ({payId,status,isPay}) {
  170 + async onLoad ({ payId, status, isPay }) {
167 171 this.payId = payId
168 172 this.status = status
169 173 this.isPay = isPay
... ... @@ -175,216 +179,217 @@ export default {
175 179 await store.dispatch('orderRead/getOrderInfo', {
176 180 pay_id: this.payId,
177 181 uid: uid,
178   - openid: openid
179   - });
180   - // console.log(this.$store.state.orderRead.orderInfo)
181   - this.orderInfo = this.$store.state.orderRead.orderInfo
182   - this.totalPrice = this.orderInfo.total_fee
  182 + openid: openid,
  183 + })
  184 + this.totalPrice = this.orderInfo.total_fee
183 185 },
184 186 // 若从支付页面跳转过来,返回直接返回到首页
185 187 onBackPress(option) {
186   - if (option.from === "backbutton" && this.isPay) {
  188 + if (option.from === 'backbutton' && this.isPay) {
187 189 uni.switchTab({
188   - url: "/pages/index/index"
189   - });
190   - return true; // 阻止默认返回行为
  190 + url: '/pages/index/index',
  191 + })
  192 + return true // 阻止默认返回行为
191 193 }
192 194 },
193 195 computed: {
194   - orderInfoList () {
195   - return this.orderInfo.order_info?this.orderInfo.order_info.list:null
  196 + orderInfo() {
  197 + return this.$store.state.orderRead.orderInfo
  198 + },
  199 + orderInfoList () {
  200 + return this.orderInfo.order_info ? this.orderInfo.order_info.list : null
196 201 },
197 202 // 获取订单地址信息
198   - orderAddressInfo () {
199   - return this.orderInfo.order_info?this.orderInfo.order_info.address:null
  203 + orderAddressInfo () {
  204 + return this.orderInfo.order_info ? this.orderInfo.order_info.address : null
200 205 },
201 206 // 订单付款时间
202   - getLeftTime () {
203   - return this.orderInfo.order_info?this.orderInfo.order_info.lefttime:1800
  207 + getLeftTime () {
  208 + return this.orderInfo.order_info ? this.orderInfo.order_info.lefttime : 1800
204 209 },
205 210 // 计算总优惠额
206 211 totalDiscount() {
207   - const discountInfoList = this.orderInfo.discount_info;
208   - let totalDiscount = 0;
  212 + const discountInfoList = this.orderInfo.discount_info
  213 + let totalDiscount = 0
209 214 if (discountInfoList) {
210 215 discountInfoList.map((discountItem, index) => {
211   - totalDiscount += Number(discountItem.value);
212   - });
  216 + totalDiscount += Number(discountItem.value)
  217 + })
213 218 }
214 219 // console.log(totalDiscount)
215   - return totalDiscount;
216   - }
217   - },
218   -
219   - methods: {
220   - //再次购买 暂时只支持跳转第一个商品
221   - toDetail(){
222   - const pid = this.orderInfo.order_info.list[0].pid
223   - uni.navigateTo({
224   - url: '../details/details?pid='+pid,
225   - fail: (res) => {console.log(res)},
226   - });
227   - },
  220 + return totalDiscount
  221 + },
  222 + },
  223 +
  224 + methods: {
  225 + // 再次购买 暂时只支持跳转第一个商品
  226 + toDetail() {
  227 + const pid = this.orderInfo.order_info.list[0].pid
  228 + uni.navigateTo({
  229 + url: '../details/details?pid=' + pid,
  230 + fail: (res) => { console.log(res) },
  231 + })
  232 + },
228 233 // 取消订单
229 234 timeup() {
230   - this.cancleOrder();
  235 + this.cancleOrder()
231 236 },
232 237 cancleOrder() {
233   - const uid = this.uid;
234   - const openid = this.openid;
235   - const keyname = this.orderInfo.order_info.keyname
236   - // console.log('keyname',this.orderInfo.keyname)
  238 + const uid = this.uid
  239 + const openid = this.openid
  240 + const keyname = this.orderInfo.order_info.keyname
  241 + // console.log('keyname',this.orderInfo.keyname)
237 242 uni.showModal({
238   - title: "提示",
239   - content: "现在取消,订单不可恢复哦,确认取消吗?",
  243 + title: '提示',
  244 + content: '现在取消,订单不可恢复哦,确认取消吗?',
240 245 success: function(res) {
241 246 if (res.confirm) {
242   - store.dispatch("cancelOrder/cancel", {
  247 + store.dispatch('cancelOrder/cancel', {
243 248 keyname: keyname,
244 249 uid: uid,
245   - openid: openid
246   - });
247   - uni.navigateBack({
248   - delta:1
249   - })
  250 + openid: openid,
  251 + })
  252 + uni.navigateBack({
  253 + delta: 1,
  254 + })
250 255 } else if (res.cancel) {
251   - console.log("用户点击取消");
  256 + console.log('用户点击取消')
252 257 }
  258 + },
  259 + })
  260 + },
  261 + paylog() {
  262 + console.log('pay', this.orderInfo)
  263 + const { data, exKeyName: keyName } = this.orderInfo
  264 + const uid = uni.getStorageSync('uid')
  265 + const timeStamp = new Date().getTime().toString()
  266 + const nonceStr = 'asfafasfasfasfasf'
  267 + // 支付参数
  268 + const fieldSet = {
  269 + openid: this.$store.state.user.userInfo.openid,
  270 + uid: this.$store.state.user.userInfo.uid,
  271 + shopid: 0,
  272 + payCate: 2020,
  273 + payMoney: this.totalPrice,
  274 + payWoodId: `fcdj-${uid}-${keyName}`,
  275 + payWoodDesc: '在【非常戴镜】的微信付款凭证',
  276 + nonceStr,
  277 + signType: 'MD5',
  278 + app_uid: 2020,
  279 + timeStamp,
  280 + keyname: keyName,
  281 + billInfo: JSON.stringify(data),
  282 + }
  283 + // 请求后台支付接口
  284 + store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
  285 + if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
  286 + const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}`
  287 + const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789'
  288 +
  289 + // 微信支付接口
  290 + uni.requestPayment({
  291 + appId: data.appid,
  292 + timeStamp,
  293 + nonceStr,
  294 + total_fee: this.totalPrice,
  295 + package: `prepay_id=${data.prepay_id}`,
  296 + signType: 'MD5',
  297 + paySign: MD5Util.MD5(stringSignTemp).toUpperCase(),
  298 + success: (res) => {
  299 + // 支付成功
  300 + uni.showModal({
  301 + content: '支付成功',
  302 + showCancel: false,
  303 + })
  304 + // 跳转订单详情页->状态 待收货
  305 + uni.reLaunch({
  306 + url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`,
  307 + })
  308 + },
  309 + fail: (res) => {
  310 + // 支付失败
  311 + uni.showModal({
  312 + content: '支付失败',
  313 + showCancel: false,
  314 + })
  315 + // 跳转订单详情页->刷新本页面
  316 + // uni.redirectTo({
  317 + // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`,
  318 + // })
  319 + },
  320 + complete: () => {
  321 + uni.hideLoading()
  322 + },
  323 + })
  324 + } else {
  325 + uni.showModal({
  326 + content: '支付失败',
  327 + showCancel: false,
  328 + })
  329 + console.log('支付失败')
  330 + uni.hideLoading()
  331 + // uni.redirectTo({
  332 + // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`,
  333 + // })
253 334 }
254   - });
  335 + })
  336 +
  337 + // 修改订单状态 待付款==>待收货
  338 + store.dispatch('statusConfirm/confirm', {
  339 + uid: this.uid,
  340 + openid: this.openid,
  341 + oldway: '0',
  342 + way: '1',
  343 + pay_id: this.payId,
  344 + judgeContent: '',
  345 + orderInfo: this.orderInfo.order_info,
  346 + })
  347 + .then(
  348 + // setTimeout(() => {
  349 + // uni.navigateBack();
  350 + // }, 1500)
  351 + )
255 352 },
256   - paylog() {
257   - console.log('pay',this.orderInfo)
258   - const { data, exKeyName: keyName } = this.orderInfo
259   - const uid = uni.getStorageSync('uid')
260   - const timeStamp = new Date().getTime().toString()
261   - const nonceStr = 'asfafasfasfasfasf'
262   - // 支付参数
263   - const fieldSet = {
264   - openid: this.$store.state.user.userInfo.openid,
265   - uid: this.$store.state.user.userInfo.uid,
266   - shopid: 0,
267   - payCate: 2020,
268   - payMoney: this.totalPrice,
269   - payWoodId: `fcdj-${uid}-${keyName}`,
270   - payWoodDesc: '在【非常戴镜】的微信付款凭证',
271   - nonceStr,
272   - signType: 'MD5',
273   - app_uid: 2020,
274   - timeStamp,
275   - keyname: keyName,
276   - billInfo: JSON.stringify(data),
277   - }
278   - // 请求后台支付接口
279   - store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
280   - if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
281   - const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}`
282   - const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789'
283   -
284   - // 微信支付接口
285   - uni.requestPayment({
286   - appId: data.appid,
287   - timeStamp,
288   - nonceStr,
289   - total_fee: this.totalPrice,
290   - package: `prepay_id=${data.prepay_id}`,
291   - signType: 'MD5',
292   - paySign: MD5Util.MD5(stringSignTemp).toUpperCase(),
293   - success: (res) => {
294   - // 支付成功
295   - uni.showModal({
296   - content: '支付成功',
297   - showCancel: false,
298   - })
299   - // 跳转订单详情页->状态 待收货
300   - uni.reLaunch({
301   - url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`,
302   - })
303   - },
304   - fail: (res) => {
305   - // 支付失败
306   - uni.showModal({
307   - content: '支付失败',
308   - showCancel: false,
309   - })
310   - // 跳转订单详情页->刷新本页面
311   - // uni.redirectTo({
312   - // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`,
313   - // })
314   - },
315   - complete: () => {
316   - uni.hideLoading()
317   - },
318   - })
319   - } else {
320   - uni.showModal({
321   - content: '支付失败',
322   - showCancel: false,
323   - })
324   - console.log('支付失败')
325   - uni.hideLoading()
326   - // uni.redirectTo({
327   - // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`,
328   - // })
329   - }
330   - })
331   -
332   - //修改订单状态 待付款==>待收货
333   - store.dispatch("statusConfirm/confirm", {
334   - uid: this.uid,
335   - openid: this.openid,
336   - oldway: "0",
337   - way: "1",
338   - pay_id: this.payId,
339   - judgeContent: "",
340   - orderInfo: this.orderInfo.order_info
341   - })
342   - .then(
343   - // setTimeout(() => {
344   - // uni.navigateBack();
345   - // }, 1500)
346   - );
347   - },
348   - confirmOrder() {
349   - //确认收货 way1 ==>way2
  353 + confirmOrder() {
  354 + // 确认收货 way1 ==>way2
350 355 store
351   - .dispatch("statusConfirm/confirm", {
  356 + .dispatch('statusConfirm/confirm', {
352 357 uid: this.uid,
353 358 openid: this.openid,
354   - oldway: "1",
355   - way: "2",
  359 + oldway: '1',
  360 + way: '2',
356 361 pay_id: this.payId,
357   - judgeContent: "",
358   - orderInfo: this.orderInfo.order_info
  362 + judgeContent: '',
  363 + orderInfo: this.orderInfo.order_info,
359 364 })
360   - .then((res)=>{
361   - if(res.data.code === 1){
362   - uni.showToast({
363   - title:'已确认',
364   - mask:true,
365   - duration:1500,
366   - icon:'success'
367   - })
368   - }else{
369   - uni-uni.showToast({
370   - title: '服务器错误,确认失败!',
371   - mask:true
372   - });
373   - }
374   - setTimeout(() => {
375   - uni.navigateBack();
376   - }, 1500)
377   - });
378   - }
  365 + .then((res) => {
  366 + if (res.data.code === 1) {
  367 + uni.showToast({
  368 + title: '已确认',
  369 + mask: true,
  370 + duration: 1500,
  371 + icon: 'success',
  372 + })
  373 + } else {
  374 + uni.showToast({
  375 + title: '服务器错误,确认失败!',
  376 + mask: true,
  377 + })
  378 + }
  379 + setTimeout(() => {
  380 + uni.navigateBack()
  381 + }, 1500)
  382 + })
  383 + },
379 384 },
380   - filters: {
381   - timerChange: function(value) {
382   - var newDate = new Date();
383   - newDate.setTime(value * 1000);
384   - return newDate.toLocaleString();
385   - }
386   - }
387   -};
  385 + // filters: {
  386 + // timerChange: function(value) {
  387 + // var newDate = new Date()
  388 + // newDate.setTime(value * 1000)
  389 + // return newDate.toLocaleString()
  390 + // },
  391 + // },
  392 +}
388 393 </script>
389 394  
390 395 <style lang="scss" scoped>
... ... @@ -497,6 +502,7 @@ export default {
497 502 font-size: 14px;
498 503 color: #333333;
499 504 letter-spacing: -0.26px;
  505 + line-height: 70rpx;
500 506 }
501 507 }
502 508 }
... ...