Commit eed6c3ca9b53ee18cc16870e4d22da46b33bbd01

Authored by BigBoss
1 parent 1a4cad7196
Exists in master

订单列表添加支付和取消功能,修改订单详情报错的bug

src/components/BottomSheet/BottomSheet.vue
... ... @@ -426,12 +426,6 @@ import store from '@/store'
426 426 return glassInfoArr.find(item => item == '0') ==undefined
427 427 }
428 428 },
429   - // beforeDestroy() {
430   - // //获取关心的人列表
431   - // store.dispatch('myLoveList/getLoveList', {
432   - // uid: this.$store.state.user.userInfo.uid,
433   - // });
434   - // },
435 429 created() {
436 430 this.skuValueArray = this.skuList[0].sku_value.split("_")
437 431 // console.log(this.sk_id)
... ...
src/pages/details/details.vue
... ... @@ -424,7 +424,7 @@ export default {
424 424 addCartList.mp_id = mpId
425 425 addCartList.sk_id = skId
426 426 addCartList.num = num
427   - addCartList.checkedSKU = checkedSKU
  427 + // addCartList.checkedSKU = checkedSKU
428 428 addCartList.pid = this.pid
429 429 addCartList.price = price
430 430 console.log('添加购物车的参数', addCartList)
... ...
src/pages/myOrder/components/OrderCard.vue
... ... @@ -3,7 +3,7 @@
3 3 <view
4 4 class="card"
5 5 v-if="current == status"
6   - @click="toOrderInfo(status,order.pay_id)"
  6 +
7 7 >
8 8 <view class="cardHeader">
9 9 <text
... ... @@ -30,6 +30,7 @@
30 30 </view>
31 31 <view
32 32 class="orderCardInfo"
  33 + @click="toOrderInfo(status,order.pay_id)"
33 34 v-for="(orderInfo, index) in orderInfoList"
34 35 :key="index"
35 36 >
... ... @@ -65,13 +66,13 @@
65 66 class="btns"
66 67 v-if="status == '2'"
67 68 >
68   - <view class="btn-type2" @click="toDetail">再次购买</view>
  69 + <view class="btn-type2" @click="toDetail(order.order_info[0].pid)">再次购买</view>
69 70 </view>
70 71 <!-- <view class="btns" v-if="status == '3'">
71 72 <view class="btn-type2">再次购买</view>
72 73 </view> -->
73 74 </view>
74   - <view class="card" v-if="current == '10'" @click="toOrderInfo(status,order.pay_id)">
  75 + <view class="card" v-if="current == '10'" >
75 76 <view class="cardHeader">
76 77 <text class="orderId" v-if="status == '0'||status == '1'">订单号:{{order.pay_id}}</text>
77 78 <text class="orderId" v-if="status == '2'||status == '3'">下单时间:{{order.pay_time}}</text>
... ... @@ -80,7 +81,7 @@
80 81 <text class="orderType" v-if="status == '2'||status == '3'">已完成</text>
81 82 <!-- <text class="orderType" v-if="status == '3'">已评价</text> -->
82 83 </view>
83   - <view class="orderCardInfo" v-for="(orderInfo) in orderInfoList" :key="orderInfo">
  84 + <view class="orderCardInfo" @click="toOrderInfo(status,order.pay_id)" v-for="(orderInfo) in orderInfoList" :key="orderInfo">
84 85 <image :src="orderInfo.imgUrl" mode="aspectFill"></image>
85 86 <view class="infoText">
86 87 <view class="orderName">{{orderInfo.p_name}}</view>
... ... @@ -93,8 +94,8 @@
93 94 </view>
94 95 <view class="payPrice">实付:<text class="priceNum">{{order.total_fee}}</text> </view>
95 96 <view class="btns" v-if="status == '0'">
96   - <view class="btn-type1" >取消订单</view>
97   - <view class="btn-type2">去支付</view>
  97 + <view class="btn-type1" @click="cancleOrder">取消订单</view>
  98 + <view class="btn-type2" @click="paylog">去支付</view>
98 99 </view>
99 100 <view class="btns" v-if="status == '1'">
100 101 <view class="btn-type2">确认收货</view>
... ... @@ -102,16 +103,19 @@
102 103 <view class="btns" v-if="status == '2'||status == '3'">
103 104 <view class="btn-type2" @click="toDetail(order.order_info[0].pid)">再次购买</view>
104 105 </view>
105   - <!-- <view class="btns" v-if="status == '3'">
106   -
107   - <view class="btn-type2">再次购买</view>
108   - </view> -->
109 106 </view>
110 107 </view>
111 108 </template>
112 109  
113 110 <script>
  111 + import MD5Util from '../../../utils/md5'
  112 + import store from "@/store";
114 113 export default {
  114 + data() {
  115 + return {
  116 +
  117 + };
  118 + },
115 119 props: {
116 120 /**
117 121 * 订单数据
... ... @@ -136,32 +140,142 @@
136 140 return this.order.order_info
137 141 }
138 142 },
139   - data() {
140   - return {
141   - };
142   - },
143 143 methods:{
144   - cancleOrder() {
145   - // const openid = uni.getStorageSync('openid')
146   - // const uid = this.order.uid;
147   - // const openid = openid;
148   - // const keyname = this.orderInfo.order_info.keyname
149   - // // console.log('keyname',this.orderInfo.keyname)
150   - // uni.showModal({
151   - // title: "提示",
152   - // content: "现在取消,订单不可恢复哦,确认取消吗?",
153   - // success: function(res) {
154   - // if (res.confirm) {
155   - // store.dispatch("cancelOrder/cancel", {
156   - // keyname: keyname,
157   - // uid: uid,
158   - // openid: openid
159   - // });
160   - // } else if (res.cancel) {
161   - // console.log("用户点击取消");
162   - // }
163   - // }
164   - // });
  144 + async paylog() {
  145 + const openid = uni.getStorageSync('openid')
  146 + const uid = this.order.uid;
  147 + //先拿订单详情
  148 + await store.dispatch('orderRead/getOrderInfo', {
  149 + pay_id: this.order.pay_id,
  150 + uid: uid,
  151 + openid: openid
  152 + }).then((res)=>{
  153 + // console.log(res)
  154 + const { data, exKeyName: keyName } = res.order_info
  155 + const timeStamp = new Date().getTime().toString()
  156 + const total_fee = res.total_fee
  157 + const payId = res.pay_id
  158 + const nonceStr = 'asfafasfasfasfasf'
  159 + // 支付参数
  160 + const fieldSet = {
  161 + openid: openid,
  162 + uid: uid,
  163 + shopid: 0,
  164 + payCate: 2020,
  165 + payMoney: total_fee,
  166 + payWoodId: `fcdj-${uid}-${keyName}`,
  167 + payWoodDesc: '在【非常戴镜】的微信付款凭证',
  168 + nonceStr,
  169 + signType: 'MD5',
  170 + app_uid: 2020,
  171 + timeStamp,
  172 + keyname: keyName,
  173 + billInfo: JSON.stringify(data),
  174 + }
  175 + // 请求后台支付接口
  176 + store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
  177 + if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
  178 + const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}`
  179 + const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789'
  180 +
  181 + // 微信支付接口
  182 + uni.requestPayment({
  183 + appId: data.appid,
  184 + timeStamp,
  185 + nonceStr,
  186 + total_fee: total_fee,
  187 + package: `prepay_id=${data.prepay_id}`,
  188 + signType: 'MD5',
  189 + paySign: MD5Util.MD5(stringSignTemp).toUpperCase(),
  190 + success: (res) => {
  191 + // 支付成功
  192 + uni.showModal({
  193 + content: '支付成功',
  194 + showCancel: false,
  195 + })
  196 + // //修改订单状态 待付款==>待收货
  197 + // store.dispatch("statusConfirm/confirm", {
  198 + // uid: this.uid,
  199 + // openid: this.openid,
  200 + // oldway: "0",
  201 + // way: "1",
  202 + // pay_id: payId,
  203 + // judgeContent: "",
  204 + // orderInfo: this.orderInfo.order_info
  205 + // })
  206 + },
  207 + fail: (res) => {
  208 + // 支付失败
  209 + uni.showModal({
  210 + content: '支付失败',
  211 + showCancel: false,
  212 + })
  213 + },
  214 + complete: () => {
  215 + uni.hideLoading()
  216 + },
  217 + })
  218 + } else {
  219 + uni.showModal({
  220 + content: '支付失败',
  221 + showCancel: false,
  222 + })
  223 + console.log('支付失败')
  224 + uni.hideLoading()
  225 + }
  226 + })
  227 + //修改订单状态 待付款==>待收货
  228 + // store.dispatch("statusConfirm/confirm", {
  229 + // uid: this.uid,
  230 + // openid: this.openid,
  231 + // oldway: "0",
  232 + // way: "1",
  233 + // pay_id: this.payId,
  234 + // judgeContent: "",
  235 + // orderInfo: this.orderInfo.order_info
  236 + // })
  237 + })
  238 + },
  239 +
  240 + async cancleOrder(e) {
  241 + const openid = uni.getStorageSync('openid')
  242 + const uid = this.order.uid;
  243 + //先从订单详情中拿到keyname
  244 + await store.dispatch('orderRead/getOrderInfo', {
  245 + pay_id: this.order.pay_id,
  246 + uid: uid,
  247 + openid: openid
  248 + }).then((res)=>{
  249 + const keyname = res.order_info.keyname
  250 + uni.showModal({
  251 + title: "提示",
  252 + content: "现在取消,订单不可恢复哦,确认取消吗?",
  253 + success: function(res) {
  254 + if (res.confirm) {
  255 + store.dispatch("cancelOrder/cancel", {
  256 + keyname: keyname,
  257 + uid: uid,
  258 + openid: openid
  259 + }).then((res)=>{
  260 + console.log(res)
  261 + if(res.code == 1){
  262 + store.dispatch("myOrder/getList", {
  263 + way: ""
  264 + });
  265 + }else{
  266 + uni.showToast({
  267 + title:'取消失败,服务器错误!',
  268 + icon:'none'
  269 + })
  270 + }
  271 + });
  272 + } else if (res.cancel) {
  273 + console.log("用户点击取消");
  274 + }
  275 + }
  276 + });
  277 + });
  278 +
165 279 },
166 280 toDetail(pid){
167 281 console.log('pid',pid)
... ... @@ -220,7 +334,7 @@
220 334 <style lang="scss">
221 335 .card {
222 336 width: 670rpx;
223   - height: 478rpx;
  337 + // height: 478rpx;
224 338 background: #ffffff;
225 339 box-shadow: 0 0 10px 0 rgba(177, 128, 128, 0.06);
226 340 border-radius: 8px;
... ...
src/pages/myOrder/myOrder.vue
... ... @@ -27,6 +27,7 @@
27 27 <OrderCard
28 28 :order="order"
29 29 :current="current"
  30 + v-if="order.order_info !== null"
30 31 ></OrderCard>
31 32 </view>
32 33 </view>
... ...
src/pages/myOrderPaying/myOrderPaying.vue
... ... @@ -13,21 +13,21 @@
13 13 mode="aspectFill"
14 14 ></image>
15 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="getTime"
25   - @timeup=timeup >
26   - </uni-countdown>
27   -
28   - <text>内完成付款</text>
29   - </view>
30   -
  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 31 <view class="headerBanner" v-if="status == '1'">
32 32 <view class="bannerLeft">
33 33 <view class="T1">卖家已发货</view>
... ... @@ -96,8 +96,7 @@
96 96 <text>订单号:{{payId}}</text>
97 97 </text>
98 98 <text class="order-info-time">
99   - <text>下单时间:{{orderInfo.order_info.pay_time | timerChange}}</text>
100   -
  99 + <text>下单时间:{{orderInfo.order_info?orderInfo.order_info.pay_time:'' | timerChange}}</text>
101 100 </text>
102 101 <view class="order-info-hr"></view>
103 102 <view class="order-info-contact">
... ... @@ -160,7 +159,7 @@ export default {
160 159 openid: "",
161 160 lefttime: 0,
162 161 isPay: 0,
163   - orderInfo:Object,
  162 + orderInfo:{},
164 163 totalPrice:0,
165 164 };
166 165 },
... ... @@ -168,7 +167,7 @@ export default {
168 167 this.payId = payId
169 168 this.status = status
170 169 this.isPay = isPay
171   - console.log('++++++++++++++++++',this.status)
  170 + // console.log('++++++++++++++++++',this.status)
172 171 const openid = uni.getStorageSync('openid')
173 172 const uid = this.$store.state.user.userInfo.uid
174 173 this.uid = uid
... ... @@ -192,17 +191,16 @@ export default {
192 191 }
193 192 },
194 193 computed: {
195   - orderInfoList () {
196   - return this.orderInfo.order_info.list
  194 + orderInfoList () {
  195 + return this.orderInfo.order_info?this.orderInfo.order_info.list:null
197 196 },
198 197 // 获取订单地址信息
199   - orderAddressInfo () {
200   - return this.orderInfo.order_info.address
  198 + orderAddressInfo () {
  199 + return this.orderInfo.order_info?this.orderInfo.order_info.address:null
201 200 },
202 201 // 订单付款时间
203   - getTime () {
204   - return this.orderInfo.order_info.lefttime
205   -
  202 + getLeftTime () {
  203 + return this.orderInfo.order_info?this.orderInfo.order_info.lefttime:1800
206 204 },
207 205 // 计算总优惠额
208 206 totalDiscount() {
... ...
src/pages/user/user.vue
... ... @@ -77,12 +77,9 @@
77 77 ></image>
78 78 </view>
79 79 <view class="myOrder">
80   - <view class="orderHeader">
  80 + <view class="orderHeader" @click="toMyOrder('10')" >
81 81 <text>我的订单</text>
82   - <view
83   - class="btn"
84   - @click="toMyOrder('10')"
85   - >
  82 + <view class="btn">
86 83 全部
87 84 <image
88 85 src="../../static/right.png"
... ...
src/store/modules/cancelOrder.js
... ... @@ -5,32 +5,21 @@ const {
5 5 cancelOrder
6 6 } = urlAlias;
7 7  
8   -const state = {
9   - orderList: [],
10   -};
11   -
12   -const mutations = {
13   - INIT: (state, data) => {
14   - state.orderList = data;
15   - },
16   -};
17   -
18 8 const actions = {
19 9 cancel({ commit }, param) {
20   - request({
21   - url: cancelOrder,
22   - data: param,
23   - success: (res) => {
24   - console.log(res.data);
25   - // commit("INIT", res.data.data);
26   - },
27   - })
  10 + return new Promise((resolve)=>
  11 + request({
  12 + url: cancelOrder,
  13 + data: param,
  14 + success: (res) => {
  15 + // console.log(res.data);
  16 + resolve(res.data)
  17 + },
  18 + }) )
28 19 }
29 20 }
30 21  
31 22 export default {
32 23 namespaced: true,
33   - state,
34   - mutations,
35 24 actions,
36 25 }
37 26 \ No newline at end of file
... ...
src/store/modules/orderRead.js
... ... @@ -20,7 +20,8 @@ const actions = {
20 20 return new Promise ((resolve) => request({
21 21 url: orderRead,
22 22 data: param,
23   - success: (res) => {
  23 + success: (res) => {
  24 + console.log(res)
24 25 commit("INIT", res.data.data)
25 26 resolve(res.data.data)
26 27 }
... ...