Commit 34703a7672c876bc05320083bb8e836d07175cdd

Authored by BigBoss
1 parent 5b12ec0b65
Exists in master

订单逻辑修改

src/pages/myOrder/components/OrderCard.vue
... ... @@ -65,7 +65,7 @@
65 65 class="btns"
66 66 v-if="status == '2'"
67 67 >
68   - <view class="btn-type2">再次购买</view>
  68 + <view class="btn-type2" @click="toDetail">再次购买</view>
69 69 </view>
70 70 <!-- <view class="btns" v-if="status == '3'">
71 71 <view class="btn-type2">再次购买</view>
... ... @@ -73,7 +73,7 @@
73 73 </view>
74 74 <view class="card" v-if="current == '10'" @click="toOrderInfo(status,order.pay_id)">
75 75 <view class="cardHeader">
76   - <text class="orderId" v-if="status == '0'||status == '1'">订单号:{{order.mch_id}}</text>
  76 + <text class="orderId" v-if="status == '0'||status == '1'">订单号:{{order.pay_id}}</text>
77 77 <text class="orderId" v-if="status == '2'||status == '3'">下单时间:{{order.pay_time}}</text>
78 78 <text class="orderType" v-if="status=='0'">待付款</text>
79 79 <text class="orderType" v-if="status=='1'">待收货</text>
... ... @@ -100,7 +100,7 @@
100 100 <view class="btn-type2">确认收货</view>
101 101 </view>
102 102 <view class="btns" v-if="status == '2'||status == '3'">
103   - <view class="btn-type2">再次购买</view>
  103 + <view class="btn-type2" @click="toDetail(order.order_info[0].pid)">再次购买</view>
104 104 </view>
105 105 <!-- <view class="btns" v-if="status == '3'">
106 106  
... ... @@ -124,7 +124,7 @@
124 124  
125 125 },
126 126 created() {
127   - console.log(this.order);
  127 + console.log('order',this.order);
128 128 // console.log(this.order.status );
129 129 // console.log(this.current);
130 130 },
... ... @@ -133,7 +133,6 @@
133 133 return this.order.status
134 134 },
135 135 orderInfoList(){
136   - console.log('orderInfoList', this.order.order_info)
137 136 return this.order.order_info
138 137 }
139 138 },
... ... @@ -142,6 +141,13 @@
142 141 };
143 142 },
144 143 methods:{
  144 + toDetail(pid){
  145 + console.log('pid',pid)
  146 + uni.navigateTo({
  147 + url: '../details/details?pid='+pid,
  148 + fail: (res) => {console.log(res)},
  149 + });
  150 + },
145 151 toRefundment(){
146 152 uni.navigateTo({
147 153 url: '../refundment/refundment',
... ...
src/pages/myOrder/myOrder.vue
... ... @@ -48,7 +48,7 @@ export default {
48 48 { current: "10", text: "全部" },
49 49 { current: "0", text: "待付款" },
50 50 { current: "1", text: "待收货" },
51   - { current: "2", text: "待评价" }
  51 + { current: "2", text: "已完成" }
52 52 // {current:"3",text:'已评价'},
53 53 // {current:"4",text:'退款'},
54 54 ],
... ... @@ -57,11 +57,16 @@ export default {
57 57 };
58 58 },
59 59  
  60 +onShow() {
  61 + store.dispatch("myOrder/getList", {
  62 + way: ""
  63 + });
  64 +},
60 65 onLoad: function(option) {
61 66 // 获取订单列表
62   - store.dispatch("myOrder/getList", {
63   - way: ""
64   - });
  67 + // store.dispatch("myOrder/getList", {
  68 + // way: ""
  69 + // });
65 70 // 从user过来传的status,给current,以显示对应item
66 71 this.current = option.status;
67 72 },
... ... @@ -74,7 +79,6 @@ export default {
74 79 methods: {
75 80 // tab点击事件
76 81 onClickItem(e) {
77   - console.log("onClickItem", e);
78 82 if (this.current !== e) {
79 83 this.current = e;
80 84 }
... ...
src/pages/myOrderPaying/myOrderPaying.vue
... ... @@ -125,12 +125,13 @@
125 125 </template>
126 126  
127 127 <script>
128   -import store from "@/store";
  128 +import store from "@/store";
  129 +import MD5Util from '../../utils/md5'
129 130 import UniCountdown from "../../components/UniCountdown/UniCountdown.vue";
130 131 export default {
131 132 components: {
132 133 UniCountdown
133   - },
  134 + },
134 135 data() {
135 136 return {
136 137 payId: "",
... ... @@ -140,7 +141,8 @@ export default {
140 141 openid: "",
141 142 lefttime: 0,
142 143 isPay: 0,
143   - orderInfo:Object
  144 + orderInfo:Object,
  145 + totalPrice:0,
144 146 };
145 147 },
146 148 onLoad:async function ({payId,status,isPay}) {
... ... @@ -157,8 +159,9 @@ export default {
157 159 uid: uid,
158 160 openid: openid
159 161 });
160   - console.log(this.$store.state.orderRead.orderInfo)
161   - this.orderInfo = this.$store.state.orderRead.orderInfo
  162 + // console.log(this.$store.state.orderRead.orderInfo)
  163 + this.orderInfo = this.$store.state.orderRead.orderInfo
  164 + this.totalPrice = this.orderInfo.total_fee
162 165 },
163 166 // 若从支付页面跳转过来,返回直接返回到首页
164 167 onBackPress(option) {
... ... @@ -226,76 +229,79 @@ export default {
226 229 },
227 230 paylog() {
228 231 console.log('pay',this.orderInfo)
229   - // const { data, exKeyName: keyName } = res
230   - // const uid = uni.getStorageSync('uid')
231   - // const timeStamp = new Date().getTime().toString()
232   - // const nonceStr = 'asfafasfasfasfasf'
233   - // // 支付参数
234   - // const fieldSet = {
235   - // openid: this.$store.state.user.userInfo.openid,
236   - // uid: this.$store.state.user.userInfo.uid,
237   - // shopid: 0,
238   - // payCate: 2020,
239   - // payMoney: this.totalPrice,
240   - // payWoodId: `fcdj-${uid}-${keyName}`,
241   - // payWoodDesc: '在【非常戴镜】的微信付款凭证',
242   - // nonceStr,
243   - // signType: 'MD5',
244   - // app_uid: 2020,
245   - // timeStamp,
246   - // keyname: keyName,
247   - // billInfo: JSON.stringify(data),
248   - // }
249   - // // 请求后台支付接口
250   - // store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
251   - // if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
252   - // const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}`
253   - // const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789'
  232 + const { data, exKeyName: keyName } = this.orderInfo
  233 + const uid = uni.getStorageSync('uid')
  234 + const timeStamp = new Date().getTime().toString()
  235 + const nonceStr = 'asfafasfasfasfasf'
  236 + // 支付参数
  237 + const fieldSet = {
  238 + openid: this.$store.state.user.userInfo.openid,
  239 + uid: this.$store.state.user.userInfo.uid,
  240 + shopid: 0,
  241 + payCate: 2020,
  242 + payMoney: this.totalPrice,
  243 + payWoodId: `fcdj-${uid}-${keyName}`,
  244 + payWoodDesc: '在【非常戴镜】的微信付款凭证',
  245 + nonceStr,
  246 + signType: 'MD5',
  247 + app_uid: 2020,
  248 + timeStamp,
  249 + keyname: keyName,
  250 + billInfo: JSON.stringify(data),
  251 + }
  252 + // 请求后台支付接口
  253 + store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
  254 + if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
  255 + const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}`
  256 + const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789'
254 257  
255   - // // 微信支付接口
256   - // uni.requestPayment({
257   - // appId: data.appid,
258   - // timeStamp,
259   - // nonceStr,
260   - // total_fee: this.totalPrice,
261   - // package: `prepay_id=${data.prepay_id}`,
262   - // signType: 'MD5',
263   - // paySign: MD5Util.MD5(stringSignTemp).toUpperCase(),
264   - // success: (res) => {
265   - // // 支付成功
266   - // uni.showModal({
267   - // content: '支付成功',
268   - // showCancel: false,
269   - // })
270   - // // 跳转订单详情页->状态 待收货
271   - // uni.reLaunch({
272   - // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`,
273   - // })
274   - // },
275   - // fail: (res) => {
276   - // // 支付失败
277   - // uni.showModal({
278   - // content: '支付失败',
279   - // showCancel: false,
280   - // })
281   - // // 跳转订单详情页->状态 待付款
282   - // uni.reLaunch({
283   - // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`,
284   - // })
285   - // },
286   - // complete: () => {
287   - // uni.hideLoading()
288   - // },
289   - // })
290   - // } else {
291   - // uni.showModal({
292   - // content: '支付失败',
293   - // showCancel: false,
294   - // })
295   - // console.log('支付失败')
296   - // uni.hideLoading()
297   - // }
298   - // })
  258 + // 微信支付接口
  259 + uni.requestPayment({
  260 + appId: data.appid,
  261 + timeStamp,
  262 + nonceStr,
  263 + total_fee: this.totalPrice,
  264 + package: `prepay_id=${data.prepay_id}`,
  265 + signType: 'MD5',
  266 + paySign: MD5Util.MD5(stringSignTemp).toUpperCase(),
  267 + success: (res) => {
  268 + // 支付成功
  269 + uni.showModal({
  270 + content: '支付成功',
  271 + showCancel: false,
  272 + })
  273 + // 跳转订单详情页->状态 待收货
  274 + uni.reLaunch({
  275 + url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=2&isPay=1`,
  276 + })
  277 + },
  278 + fail: (res) => {
  279 + // 支付失败
  280 + uni.showModal({
  281 + content: '支付失败',
  282 + showCancel: false,
  283 + })
  284 + // 跳转订单详情页->刷新本页面
  285 + uni.redirectTo({
  286 + url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`,
  287 + })
  288 + },
  289 + complete: () => {
  290 + uni.hideLoading()
  291 + },
  292 + })
  293 + } else {
  294 + uni.showModal({
  295 + content: '支付失败',
  296 + showCancel: false,
  297 + })
  298 + console.log('支付失败')
  299 + uni.hideLoading()
  300 + uni.redirectTo({
  301 + url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`,
  302 + })
  303 + }
  304 + })
299 305  
300 306 //修改订单状态 待付款==>待收货
301 307 store.dispatch("statusConfirm/confirm", {
... ... @@ -308,9 +314,9 @@ export default {
308 314 orderInfo: this.orderInfo.order_info
309 315 })
310 316 .then(
311   - setTimeout(() => {
312   - uni.navigateBack();
313   - }, 1500)
  317 + // setTimeout(() => {
  318 + // uni.navigateBack();
  319 + // }, 1500)
314 320 );
315 321 },
316 322 confirmOrder() {
... ... @@ -325,11 +331,24 @@ export default {
325 331 judgeContent: "",
326 332 orderInfo: this.orderInfo.order_info
327 333 })
328   - .then(
329   - setTimeout(() => {
330   - uni.navigateBack();
331   - }, 1500)
332   - );
  334 + .then((res)=>{
  335 + if(res.data.code === 1){
  336 + uni.showToast({
  337 + title:'已确认',
  338 + mask:true,
  339 + duration:1500,
  340 + icon:'success'
  341 + })
  342 + }else{
  343 + uni-uni.showToast({
  344 + title: '服务器错误,确认失败!',
  345 + mask:true
  346 + });
  347 + }
  348 + setTimeout(() => {
  349 + uni.navigateBack();
  350 + }, 1500)
  351 + });
333 352 }
334 353 },
335 354 filters: {
... ...
src/store/modules/statusConfirm.js
... ... @@ -13,19 +13,7 @@ const actions = {
13 13 data: param|| { },
14 14 success: (res) => {
15 15 console.log(res.data);
16   - if(res.data.code === 1){
17   - uni.showToast({
18   - title:'已确认',
19   - mask:true,
20   - duration:1500,
21   - icon:'success'
22   - })
23   - }else{
24   - uni-uni.showToast({
25   - title: '服务器错误,确认失败!',
26   - mask:true
27   - });
28   - }
  16 +
29 17 },
30 18 })
31 19 }
... ...