diff --git a/src/components/CommodityCard/CommodityCard.vue b/src/components/CommodityCard/CommodityCard.vue index 2154ff3..1ce494a 100644 --- a/src/components/CommodityCard/CommodityCard.vue +++ b/src/components/CommodityCard/CommodityCard.vue @@ -47,10 +47,10 @@ export default { } }, methods: { - toGoods (id, sk_id) { - console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id) + toGoods (id, skId) { + console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId) uni.navigateTo({ - url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id, + url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId, success: res => {}, fail: () => {}, complete: () => {}, diff --git a/src/pages/cart/cart.vue b/src/pages/cart/cart.vue index 667d54a..a6fbf0d 100644 --- a/src/pages/cart/cart.vue +++ b/src/pages/cart/cart.vue @@ -1,78 +1,112 @@ <template> - <view class="content"> - <block v-if="cartList.length==0"> + <view class="content"> + <block v-if="cartList.length==0"> - </block> - <block v-else> - <view class="card"> - <view class="cardHeader"> - <view v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'" - @tap="pChange(pIsoPen)"> - <span class="correct"></span> - </view> - <image src="../../static/store.png" mode="aspectFill"></image> - <text>非常戴镜</text> - </view> + </block> + <block v-else> + <view class="card"> + <view class="cardHeader"> + <view + v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'" + @tap="pChange(pIsoPen)" + > + <span class="correct"></span> + </view> + <image + src="../../static/store.png" + mode="aspectFill" + ></image> + <text>非常戴镜</text> + </view> - <view class="cardBody" v-for="(item,index) in cartList" :key="item.cart_id" - @longpress="delCart(item.cart_id,index)"> - <view v-bind:class="childIsOpen[index]? 'partentChecked':'partentCheck'" - @tap="Change(childIsOpen[index],index)"> - <span class="correct"></span> - </view> - <view class="imageWrap"> - <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image> - </view> - <view class="goodInfo"> -<!-- <view class="imageWrap"> + <view + class="cardBody" + v-for="(item,index) in cartList" + :key="item.cart_id" + @longpress="delCart(item.cart_id,index)" + > + <view + v-bind:class="childIsOpen[index]? 'partentChecked':'partentCheck'" + @tap="Change(childIsOpen[index],index)" + > + <span class="correct"></span> + </view> + <view class="imageWrap"> + <image + :src="item.img_index_url" + mode="aspectFit" + style="width: 188rpx;height: 168rpx;" + ></image> + </view> + <view class="goodInfo"> + <!-- <view class="imageWrap"> <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image> </view> --> - <view class="infoRight"> - <view class="goodName" @tap="toGoods(item.pid,item.sk_id)">{{item.p_name}}</view> - <!-- <view class="describ"> --> - <uni-collapse accordion="true" > - <uni-collapse-item showAnimation='true' - :title="item.tag.prod_tag_fun[0].label+'/'+item.tag.prod_tag_fun[1].label+'/'+item.tag.prod_tag_fun[2].label+'...' || '暂无'" > - <text class="describ"> - <block v-for="tag in item.tag.prod_tag_fun" :key="tag.value"> - {{tag.label+` `}} - </block> - </text> -<!-- <text> + <view class="infoRight"> + <view + class="goodName" + @tap="toGoods(item.pid,item.sk_id)" + >{{item.p_name}}</view> + <!-- <view class="describ"> --> + <uni-collapse accordion="true"> + <uni-collapse-item + showAnimation='true' + :title="item.tag.prod_tag_fun[0].label+'/'+item.tag.prod_tag_fun[1].label+'/'+item.tag.prod_tag_fun[2].label+'...' || '暂无'" + > + <text class="describ"> + <block + v-for="tag in item.tag.prod_tag_fun" + :key="tag.value" + > + {{tag.label+` `}} + </block> + </text> + <!-- <text> <block v-for="tag in item.tag.prod_tag_style" :key="tag.value"> {{tag.label+` `}} </block> </text> --> - </uni-collapse-item> - </uni-collapse> - <!-- <view v-bind:class="collapseList[index]? 'icon':'iconed'"></view> --> - <!-- </view> --> - <view class="priceBox"> - <view class="price">¥{{item.nowPrice*item.num}}</view> - <text class="maxCount">(限购{{maxCount}}副)</text> - <view class="counter"> - <view class="btn" disabled="this.addDisabled" type="default" - @tap="counter(index,false,item)">-</view> - <text>{{item.num}}</text> - <view class="btn" disabled="this.desDisabled" type="default" - @tap="counter(index,true,item)">+</view> - </view> - </view> - </view> - </view> - </view> - </view> - </block> - <view class="footer"> - <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view> - <view class="footerRight"> - <navigator url="/pages/confirmOrder/confirmOrder" hover-class="navigator-hover"> - <view class="paybtn" >立即结算</view> - </navigator> - </view> - </view> + </uni-collapse-item> + </uni-collapse> + <!-- <view v-bind:class="collapseList[index]? 'icon':'iconed'"></view> --> + <!-- </view> --> + <view class="priceBox"> + <view class="price">¥{{item.nowPrice*item.num}}</view> + <text class="maxCount">(限购{{maxCount}}副)</text> + <view class="counter"> + <view + class="btn" + disabled="this.addDisabled" + type="default" + @tap="counter(index,false,item)" + >-</view> + <text>{{item.num}}</text> + <view + class="btn" + disabled="this.desDisabled" + type="default" + @tap="counter(index,true,item)" + >+</view> + </view> + </view> + </view> + </view> + </view> + </view> + </block> + <view class="footer"> + <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view> + <view class="footerRight"> + <navigator + url="/pages/confirmOrder/confirmOrder" + hover-class="navigator-hover" + > + <view class="paybtn">立即结算</view> + </navigator> + </view> + </view> - </view> + </view> </template> <script> @@ -87,7 +121,7 @@ export default { totalPrice: 0, pIsoPen: false, // childIsOpen:[], - maxCount: 20 + maxCount: 20, } }, computed: { @@ -104,34 +138,34 @@ export default { } console.log('this.childisOPne===>', temp) return temp - } + }, }, onLoad: function() { // store.dispatch('cart/addCart', { // uid: this.$store.state.user.userInfo.uid, - // openid: this.$store.state.user.userInfo.openid, - // mp_id: 7, - // sk_id: 7, - // num: 1, - // pid: 8, - // price: 128, - // checkedSKU:{}, + // openid: this.$store.state.user.userInfo.openid, + // mp_id: 7, + // sk_id: 7, + // num: 1, + // pid: 8, + // price: 128, + // checkedSKU:{}, // }) store.dispatch('cart/getCartList', { - uid: this.$store.state.user.userInfo.uid // 用户id + uid: this.$store.state.user.userInfo.uid, // 用户id }) }, methods: { toGoods(id, sk_id) { - console.log('cart-list', this.$store.state.cart.cartList); - console.log('---', '../frameDetail/frameDetail?pid=' + id +'&sk_id='+sk_id) + console.log('cart-list', this.$store.state.cart.cartList) + console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id) uni.navigateTo({ - url: '../frameDetail/frameDetail?pid=' + id+'&sk_id='+sk_id, + url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id, success: res => {}, fail: () => {}, - complete: () => {} + complete: () => {}, }) // uni.navigateTo({ // url: '../frameDetail/frameDetail?oderId=' + id, @@ -181,9 +215,9 @@ export default { counter(index, isadd, item) { // console.log('===>>counter ===>num',num) // console.log('===>>counter ===>isadd',isadd) - console.log('item=====>',item) - console.log('num=====>',item.num) - let nums = parseInt(item.num) + console.log('item=====>', item) + console.log('num=====>', item.num) + const nums = parseInt(item.num) if (isadd) { if (nums >= this.maxCount) { this.addDisabled = true @@ -198,14 +232,14 @@ export default { openid: this.$store.state.user.userInfo.openid, mp_id: item.mp_id, sk_id: item.sk_id, - price: item.nowPrice, - pid: item.pid, + price: item.nowPrice, + pid: item.pid, num: nums + 1, - cart_id: item.cart_id, + cart_id: item.cart_id, args: { index: index, - isadd: isadd - } + isadd: isadd, + }, }) this.addDisabled = false } @@ -216,21 +250,21 @@ export default { this.desDisabled = false // post 请求修改相关参数 if (this.childIsOpen[index]) { - this.totalPrice = this.totalPrice - this.$store.state.cart.cartList[index].nowPrice + this.totalPrice = this.totalPrice - this.$store.state.cart.cartList[index].nowPrice } store.dispatch('cart/modiCart', { uid: this.$store.state.user.userInfo.uid, openid: this.$store.state.user.userInfo.openid, mp_id: item.mp_id, sk_id: item.sk_id, - price: item.nowPrice, - pid: item.pid, + price: item.nowPrice, + pid: item.pid, num: nums - 1, - cart_id: item.cart_id, + cart_id: item.cart_id, args: { index: index, - isadd: isadd - } + isadd: isadd, + }, }) this.desDisabled = true } @@ -282,8 +316,8 @@ export default { // console.log('delcart------>cart_id',cart_id) // console.log('cartlist====>delcart',this.$store.state.cart.cartList) // console.log('delcart======>index',index) - const uid=this.$store.state.user.userInfo.uid - const openid=this.$store.state.user.userInfo.openid + const uid = this.$store.state.user.userInfo.uid + const openid = this.$store.state.user.userInfo.openid uni.showModal({ title: '是否删除该商品', // content: '是否删除该商品', @@ -294,261 +328,259 @@ export default { uid: uid, openid: openid, cart_id: cart_id, // 要修改的购物车id - arg: index // 由于action 传参是能接收两参数,因此将index放入对象 + arg: index, // 由于action 传参是能接收两参数,因此将index放入对象 }) console.log('用户点击确定') } - } + }, }) - } - } + }, + }, } </script> <style lang="scss"> .content { - min-height: 100vh; - background-color: #f2f2f2; - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - padding: 20rpx 40rpx; - box-sizing: border-box; - - .partentCheck{ - width: 16px; - height: 16px; - border-radius: 22px; - border: 1px solid #CFCFCF; - background-color: #FFFFFF; - margin: 6px; - } - .partentChecked{ - width: 18px; - height: 18px; - border-radius: 22px; - background-color: #FF6B4A; - margin: 6px; - .correct { - display: inline-block; - position: relative; - width: 10rpx; - height: 2rpx; - background: #FFFFFF; - line-height: 0; - font-size: 0; - position: relative; - top: -7px; - left: 4px; - -webkit-transform: rotate(45deg); - } - .correct:after { - content: '/'; - display: block; - width: 16rpx; - height: 2rpx; - background: #FFFFFF; - -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%); - } - } - - .card{ - background-color: #FFFFFF; - border-radius: 16rpx; - box-sizing: border-box; - padding: 36rpx 36rpx 36rpx 18rpx; - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - margin-bottom: 180rpx; - .cardHeader{ - width: 100%; - height: 36rpx; - display: flex; - align-items: center; - justify-content: flex-start; - margin-bottom: 20rpx; - image{ - height: 32rpx; - width: 32rpx; - padding-left: 6px; - padding-right: 10px; - } - text{ - // font-family: PingFangSC-Regular; - font-size: 14px; - color: #333333; - letter-spacing: -0.26px; - } - } - .cardBody{ - width: 100%; - min-height: 300rpx; - display: flex; - align-items: center; - justify-content: space-between; - .goodInfo{ - width: 390rpx; - display: flex; - flex-direction: row; - justify-content: flex-start; - padding-left: 6px; + min-height: 100vh; + background-color: #f2f2f2; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + padding: 20rpx 40rpx; + box-sizing: border-box; - .imageWrap{ - height: 188rpx; - width: 188rpx; - margin-right: 28rpx; + .partentCheck { + width: 16px; + height: 16px; + border-radius: 22px; + border: 1px solid #cfcfcf; + background-color: #ffffff; + margin: 6px; + } + .partentChecked { + width: 18px; + height: 18px; + border-radius: 22px; + background-color: #ff6b4a; + margin: 6px; + .correct { + display: inline-block; + position: relative; + width: 10rpx; + height: 2rpx; + background: #ffffff; + line-height: 0; + font-size: 0; + position: relative; + top: -7px; + left: 4px; + -webkit-transform: rotate(45deg); + } + .correct:after { + content: "/"; + display: block; + width: 16rpx; + height: 2rpx; + background: #ffffff; + -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%); + } + } - image{ - border-radius: 4px; - height: 188rpx; - width: 188rpx; - } - } - .infoRight{ - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: space-between; - min-height: 240rpx; - .goodName{ - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - text-align: justify; - overflow: hidden; - font-size: 28rpx; - color: #333333; - } - .describ{ - width: 100%; - // min-height: 80rpx; - // box-sizing: border-box; - // padding: 10rpx; - font-size: 20rpx; - letter-spacing: -0.23px; - text-align: justify; - color: #999999; - // background: #F9F9F9; - // display: flex; - // justify-content: center; - // align-items: center; - // text{ - // text-overflow: -o-ellipsis-lastline; - // overflow: hidden; - // text-overflow: ellipsis; - // display: -webkit-box; - // -webkit-line-clamp: 2; - // line-clamp: 2; - // -webkit-box-orient: vertical; - // } - // .icon { - // width: 0; - // height: 0; - // border-left: 5px transparent; - // border-right: 5px transparent; - // border-top: 5px #979797; - // border-bottom: 0 transparent; - // border-style: solid; - // position: relative; - // margin-left: 10px; - // // transform: scaleY(-1); - // } - // .icon::after{ - // content: ''; - // position: absolute; - // top: -6.5px; - // left: -5px; - // border-left: 5px transparent; - // border-right: 5px transparent; - // border-top: 5px #FFFFFF; - // border-bottom: 0 transparent; - // border-style: solid; - // } - } - .priceBox{ - display: flex; - justify-content: space-between; - align-items: center; - // margin-top: 26px; - width: 100%; - font-size: 14px; - color: #999999; - .maxCount{ - color: #999999; - font-size: 24rpx; - } - .price{ - color: #FF6B4A; - font-size: 28rpx; - } - .counter{ - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - font-size: 28rpx; - color: #333333; - width: 122rpx; - .btn{ - display: flex; - justify-content: center; - line-height: 32rpx; - height: 32rpx; - width: 32rpx; - background-color: #F2F2F2; - color: #CFCFCF; - } - } - } - } - } - } - } + .card { + background-color: #ffffff; + border-radius: 16rpx; + box-sizing: border-box; + padding: 36rpx 36rpx 36rpx 18rpx; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + margin-bottom: 180rpx; + .cardHeader { + width: 100%; + height: 36rpx; + display: flex; + align-items: center; + justify-content: flex-start; + margin-bottom: 20rpx; + image { + height: 32rpx; + width: 32rpx; + padding-left: 6px; + padding-right: 10px; + } + text { + // font-family: PingFangSC-Regular; + font-size: 14px; + color: #333333; + letter-spacing: -0.26px; + } + } + .cardBody { + width: 100%; + min-height: 300rpx; + display: flex; + align-items: center; + justify-content: space-between; + .goodInfo { + width: 390rpx; + display: flex; + flex-direction: row; + justify-content: flex-start; + padding-left: 6px; - .footer{ - position: fixed; - left: 0; - bottom: 0px; - height: 112rpx; - width: 100%; - background-color: #FFFFFF; - font-size: 16px; - display: flex; - justify-content: space-between; - align-items: center; - .footerLeft{ - display: flex; - justify-content: center; - align-items: center; - width: 50%; - color: #333333; - text{ - color: #FF6B4A; - } - } - .footerRight{ - display: flex; - justify-content: flex-end; - align-items: center; - width: 50%; - margin-right: 26rpx; - .paybtn{ - display: flex; - justify-content: center; - align-items: center; - background: #FF6B4A; - border-radius: 20px; - border-radius: 20px; - color: #FFFFFF; - width: 204rpx; - height: 80rpx; - } - } + .imageWrap { + height: 188rpx; + width: 188rpx; + margin-right: 28rpx; - } - } + image { + border-radius: 4px; + height: 188rpx; + width: 188rpx; + } + } + .infoRight { + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: space-between; + min-height: 240rpx; + .goodName { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + text-align: justify; + overflow: hidden; + font-size: 28rpx; + color: #333333; + } + .describ { + width: 100%; + // min-height: 80rpx; + // box-sizing: border-box; + // padding: 10rpx; + font-size: 20rpx; + letter-spacing: -0.23px; + text-align: justify; + color: #999999; + // background: #F9F9F9; + // display: flex; + // justify-content: center; + // align-items: center; + // text{ + // text-overflow: -o-ellipsis-lastline; + // overflow: hidden; + // text-overflow: ellipsis; + // display: -webkit-box; + // -webkit-line-clamp: 2; + // line-clamp: 2; + // -webkit-box-orient: vertical; + // } + // .icon { + // width: 0; + // height: 0; + // border-left: 5px transparent; + // border-right: 5px transparent; + // border-top: 5px #979797; + // border-bottom: 0 transparent; + // border-style: solid; + // position: relative; + // margin-left: 10px; + // // transform: scaleY(-1); + // } + // .icon::after{ + // content: ''; + // position: absolute; + // top: -6.5px; + // left: -5px; + // border-left: 5px transparent; + // border-right: 5px transparent; + // border-top: 5px #FFFFFF; + // border-bottom: 0 transparent; + // border-style: solid; + // } + } + .priceBox { + display: flex; + justify-content: space-between; + align-items: center; + // margin-top: 26px; + width: 100%; + font-size: 14px; + color: #999999; + .maxCount { + color: #999999; + font-size: 24rpx; + } + .price { + color: #ff6b4a; + font-size: 28rpx; + } + .counter { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + font-size: 28rpx; + color: #333333; + width: 122rpx; + .btn { + display: flex; + justify-content: center; + line-height: 32rpx; + height: 32rpx; + width: 32rpx; + background-color: #f2f2f2; + color: #cfcfcf; + } + } + } + } + } + } + } + .footer { + position: fixed; + left: 0; + bottom: 0px; + height: 112rpx; + width: 100%; + background-color: #ffffff; + font-size: 16px; + display: flex; + justify-content: space-between; + align-items: center; + .footerLeft { + display: flex; + justify-content: center; + align-items: center; + width: 50%; + color: #333333; + text { + color: #ff6b4a; + } + } + .footerRight { + display: flex; + justify-content: flex-end; + align-items: center; + width: 50%; + margin-right: 26rpx; + .paybtn { + display: flex; + justify-content: center; + align-items: center; + background: #ff6b4a; + border-radius: 20px; + border-radius: 20px; + color: #ffffff; + width: 204rpx; + height: 80rpx; + } + } + } +} </style> diff --git a/src/pages/confirmOrder/confirmOrder.vue b/src/pages/confirmOrder/confirmOrder.vue index 876940c..e61daf5 100644 --- a/src/pages/confirmOrder/confirmOrder.vue +++ b/src/pages/confirmOrder/confirmOrder.vue @@ -62,8 +62,8 @@ <text class="remarks">支持7天无理由退货 顺丰发货</text> <view class="priceBox"> <view class="price">¥{{Number(skuInfo.real_price) * count}}<text class="originCost"> - ¥{{parseInt(skuInfo.real_price * (1 + Number(skuInfo.discount) / 100))}} - </text></view> + ¥{{parseInt(skuInfo.real_price * (1 + Number(skuInfo.discount) / 100))}} + </text></view> <view class="counter"> <view class="btn" @@ -82,12 +82,13 @@ </view> </view> <view class="infoBottom"> - <view class="norm">规格 <text > - <!-- 长度超出变省略号未做 --> - <block - v-for="(item, index) in current" - :key="index" - >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block></block> + <view class="norm">规格 <text> + <!-- 长度超出变省略号未做 --> + <block + v-for="(item, index) in current" + :key="index" + >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block> + </block> </text></view> <view class="shippingMethod">配送方式 <text>快递</text></view> <view class="message">买家留言 @@ -171,6 +172,7 @@ <script> import store from '@/store' +import MD5Util from '../../utils/md5' export default { data() { @@ -248,6 +250,9 @@ export default { }, // 下单 orderBuild() { + uni.showLoading({ + title: '支付中', + }) console.log('this', this.$store.state) const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param store.dispatch('order/buyNow', { @@ -268,6 +273,8 @@ export default { console.log('pay', res) const { data, exKeyName: keyName } = res const uid = uni.getStorageSync('uid') + const timeStamp = new Date().getTime().toString() + const nonceStr = 'asfafasfasfasfasf' const fieldSet = { openid: this.$store.state.user.userInfo.openid, uid: this.$store.state.user.userInfo.uid, @@ -275,16 +282,55 @@ export default { payCate: 2020, payMoney: Number(this.skuInfo.real_price) * this.count * 100, payWoodId: `fcdj-${uid}-${keyName}`, - nonceStr: 'asfafasfasfasfasf', + payWoodDesc: '在【非常戴镜】的微信付款凭证', + nonceStr, signType: 'MD5', app_uid: 2020, - timeStamp: new Date().getTime().toString(), - billInfo: JSON.stringify(data), + timeStamp, keyname: keyName, + billInfo: JSON.stringify(data), } console.log('fieldSet', fieldSet) - store.dispatch('order/pay', fieldSet).then((res) => { - console.log('res', res) + store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => { + if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') { + const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}` + const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789' + uni.requestPayment({ + appId: data.appid, + timeStamp, + nonceStr, + total_fee: Number(this.skuInfo.real_price) * this.count * 100, + package: `prepay_id=${data.prepay_id}`, + signType: 'MD5', + paySign: MD5Util.MD5(stringSignTemp).toUpperCase(), + success: (res) => { + uni.showModal({ + content: '支付成功', + showCancel: false, + }) + console.log('res-----支付成功', res) + uni.reLaunch({ + url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=1&ispay=1`, + }) + }, + fail: (res) => { + uni.showModal({ + content: '支付失败', + showCancel: false, + }) + console.log('res------支付失败', res) + uni.reLaunch({ + url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=0&ispay=1`, + }) + }, + complete: () => { + uni.hideLoading() + }, + }) + } else { + console.log('支付失败') + uni.hideLoading() + } }) }, }, diff --git a/src/pages/frameDetail/frameDetail.vue b/src/pages/frameDetail/frameDetail.vue index 7f13a58..0e0511f 100644 --- a/src/pages/frameDetail/frameDetail.vue +++ b/src/pages/frameDetail/frameDetail.vue @@ -382,12 +382,12 @@ export default { }, } }, - onLoad: function ({ pid, sk_id }) { + onLoad: function ({ pid, sk_id: skId }) { this.pid = pid // console.log('sk_id=====>',sk_id) store.dispatch('read/fetch', { pid, - sk_id, + sk_id: skId, }).then(() => { this.parameter[0].slength = `${this.goodInfo.frame_width}mm` this.parameter[1].slength = `${this.goodInfo.glass_width}mm` @@ -397,7 +397,7 @@ export default { this.parameter[5].slength = `${this.goodInfo.weight}mm` this.tag = this.goodInfo.tag this.test = this.goodInfo.prodIntro1 - this.test = this.test.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ') + this.test = this.test.replace(/\<img/gi, '<img style="max-width:100%;height:auto"') // addCart this.addCartList.price = this.goodInfo.p_sale_price this.addCartList.sk_id = this.goodInfo.skuList[0].sk_id diff --git a/src/pages/myOrder/components/OrderCard.vue b/src/pages/myOrder/components/OrderCard.vue index 522e131..e84f522 100644 --- a/src/pages/myOrder/components/OrderCard.vue +++ b/src/pages/myOrder/components/OrderCard.vue @@ -9,10 +9,10 @@ <text class="orderType" v-if="status == '2'||status == '3'">已完成</text> <!-- <text class="orderType" v-if="status == '3'">已评价</text> --> </view> - <view class="orderCardInfo" v-for="(orderInfo) in orderInfoList.list" :key="orderInfo"> + <view class="orderCardInfo" v-for="(orderInfo, index) in orderInfoList.list" :key="index"> <image :src="orderInfo.imgUrl" mode="aspectFill"></image> <view class="infoText"> - <view class="orderName">{{orderInfo.p_name}}</view> + <view class="orderName">{{orderInfo[0].p_name}}</view> <view class="orderDescrib">{{orderInfo.p_name}}</view> <view class="infoText-bottom"> <view class="markPrice">{{orderInfo.nowPrice}}</view> @@ -164,6 +164,7 @@ return this.order.status }, orderInfoList(){ + console.log('this.order.order_info[0]', this.order) return this.order.order_info[0] } }, diff --git a/src/pages/myOrderPaying/myOrderPaying.vue b/src/pages/myOrderPaying/myOrderPaying.vue index 9cec7ca..5cc99a5 100644 --- a/src/pages/myOrderPaying/myOrderPaying.vue +++ b/src/pages/myOrderPaying/myOrderPaying.vue @@ -72,7 +72,7 @@ </view> --> <text class="order-info-freight"> <text class="p1">运费</text> - <text class="p2">{{orderInfo.trans_price}}</text> + <text class="p2">免运费</text> </text> <text class="order-info-discount"> <text class="p1">优惠</text> @@ -127,22 +127,24 @@ import store from '@/store' import UniCountdown from '../../components/UniCountdown/UniCountdown.vue' export default { components: { - UniCountdown + UniCountdown, }, data () { return { payId: '', payTime: '', - status: '', + status: '', // status 0 待付款 1 已发货 uid: '', openid: '', - lefttime: 0 + lefttime: 0, + isPay: 0, } }, onLoad: function (option) { console.log(option) this.payId = option.payId this.status = option.status + this.isPay = option.isPay const openid = uni.getStorageSync('openid') const uid = this.$store.state.user.uid this.uid = uid @@ -150,11 +152,19 @@ export default { store.dispatch('orderRead/getOrderInfo', { pay_id: this.payId, uid: '1', - openid: openid + openid: openid, }) - // this.orderInfo = this.$store.state.orderRead.orderInfo }, + // 若从支付页面跳转过来,返回直接返回到首页 + onBackPress(option) { + if (option.from === 'backbutton' && this.isPay) { + uni.switchTab({ + url: '/pages/index/index', + }) + return true // 阻止默认返回行为 + } + }, computed: { // 获取订单详细信息 orderInfo () { @@ -184,7 +194,7 @@ export default { } // console.log(totalDiscount) return totalDiscount - } + }, }, methods: { // 取消订单 @@ -202,12 +212,12 @@ export default { store.dispatch('cancelOrder/cancel', { keyname: '1', uid: uid, - openid: openid + openid: openid, }) } else if (res.cancel) { console.log('用户点击取消') } - } + }, }) }, paylog () { @@ -221,21 +231,21 @@ export default { way: '2', pay_id: this.payId, judgeContent: '', - orderInfo: this.orderInfo.order_info + orderInfo: this.orderInfo.order_info, }).then( setTimeout(() => { uni.navigateBack() - }, 1500) + }, 1500), ) - } + }, }, filters: { timerChange: function(value) { var newDate = new Date() newDate.setTime(value * 1000) return newDate.toLocaleString() - } - } + }, + }, } </script> diff --git a/src/utils/md5.js b/src/utils/md5.js new file mode 100644 index 0000000..758f42a --- /dev/null +++ b/src/utils/md5.js @@ -0,0 +1,261 @@ +/* + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + */ + +/* + * Configurable variables. You may need to tweak these to be compatible with + * the server-side, but the defaults work in most cases. + */ +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ +var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ +var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ + +/* + * These are the functions you'll usually want to call + * They take string arguments and return either hex or base-64 encoded strings + */ +function hex_md5(s) { + return binl2hex(core_md5(str2binl(s), s.length * chrsz)); +} + +function b64_md5(s) { + return binl2b64(core_md5(str2binl(s), s.length * chrsz)); +} + +function str_md5(s) { + return binl2str(core_md5(str2binl(s), s.length * chrsz)); +} + +function hex_hmac_md5(key, data) { + return binl2hex(core_hmac_md5(key, data)); +} + +function b64_hmac_md5(key, data) { + return binl2b64(core_hmac_md5(key, data)); +} + +function str_hmac_md5(key, data) { + return binl2str(core_hmac_md5(key, data)); +} + +/* + * Perform a simple self-test to see if the VM is working + */ +function md5_vm_test() { + return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; +} + +/* + * Calculate the MD5 of an array of little-endian words, and a bit length + */ +function core_md5(x, len) { + /* append padding */ + x[len >> 5] |= 0x80 << ((len) % 32); + x[(((len + 64) >>> 9) << 4) + 14] = len; + + var a = 1732584193; + var b = -271733879; + var c = -1732584194; + var d = 271733878; + + for (var i = 0; i < x.length; i += 16) { + var olda = a; + var oldb = b; + var oldc = c; + var oldd = d; + + a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936); + d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586); + c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819); + b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330); + a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897); + d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426); + c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341); + b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983); + a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416); + d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417); + c = md5_ff(c, d, a, b, x[i + 10], 17, -42063); + b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162); + a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682); + d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101); + c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290); + b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329); + + a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510); + d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632); + c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713); + b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302); + a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691); + d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083); + c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335); + b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848); + a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438); + d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690); + c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961); + b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501); + a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467); + d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784); + c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473); + b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734); + + a = md5_hh(a, b, c, d, x[i + 5], 4, -378558); + d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463); + c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562); + b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556); + a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060); + d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353); + c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632); + b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640); + a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174); + d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222); + c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979); + b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189); + a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487); + d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835); + c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520); + b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651); + + a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844); + d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415); + c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905); + b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055); + a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571); + d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606); + c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523); + b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799); + a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359); + d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744); + c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380); + b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649); + a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070); + d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379); + c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259); + b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551); + + a = safe_add(a, olda); + b = safe_add(b, oldb); + c = safe_add(c, oldc); + d = safe_add(d, oldd); + } + return Array(a, b, c, d); + +} + +/* + * These functions implement the four basic operations the algorithm uses. + */ +function md5_cmn(q, a, b, x, s, t) { + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); +} + +function md5_ff(a, b, c, d, x, s, t) { + return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); +} + +function md5_gg(a, b, c, d, x, s, t) { + return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); +} + +function md5_hh(a, b, c, d, x, s, t) { + return md5_cmn(b ^ c ^ d, a, b, x, s, t); +} + +function md5_ii(a, b, c, d, x, s, t) { + return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); +} + +/* + * Calculate the HMAC-MD5, of a key and some data + */ +function core_hmac_md5(key, data) { + var bkey = str2binl(key); + if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); + + var ipad = Array(16), + opad = Array(16); + for (var i = 0; i < 16; i++) { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + + var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); + return core_md5(opad.concat(hash), 512 + 128); +} + +/* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ +function safe_add(x, y) { + var lsw = (x & 0xFFFF) + (y & 0xFFFF); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} + +/* + * Bitwise rotate a 32-bit number to the left. + */ +function bit_rol(num, cnt) { + return (num << cnt) | (num >>> (32 - cnt)); +} + +/* + * Convert a string to an array of little-endian words + * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. + */ +function str2binl(str) { + var bin = Array(); + var mask = (1 << chrsz) - 1; + for (var i = 0; i < str.length * chrsz; i += chrsz) + bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32); + return bin; +} + +/* + * Convert an array of little-endian words to a string + */ +function binl2str(bin) { + var str = ""; + var mask = (1 << chrsz) - 1; + for (var i = 0; i < bin.length * 32; i += chrsz) + str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask); + return str; +} + +/* + * Convert an array of little-endian words to a hex string. + */ +function binl2hex(binarray) { + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; + var str = ""; + for (var i = 0; i < binarray.length * 4; i++) { + str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) + + hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF); + } + return str; +} + +/* + * Convert an array of little-endian words to a base-64 string + */ +function binl2b64(binarray) { + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var str = ""; + for (var i = 0; i < binarray.length * 4; i += 3) { + var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16) | + (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8) | + ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF); + for (var j = 0; j < 4; j++) { + if (i * 8 + j * 6 > binarray.length * 32) str += b64pad; + else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F); + } + } + return str; +} +module.exports = { + MD5: hex_md5 +} \ No newline at end of file