瀏覽代碼

二期需求改动

Linwei 10 月之前
父節點
當前提交
4f79f50b97

+ 5 - 0
http/api/common.js

@@ -208,6 +208,11 @@ export const confirmOrder = (data,orderId) => request({
 	method: 'POST',
 	data: data
 })
+//立即支付
+export const prePayOrder = (orderId) => request({
+	url: `/open/wechat/order/prePay/${orderId}`,
+	method: 'POST'
+})
 //确认订单页面中取消订单
 export const cancelOrderByConfirm = (orderId) => request({
 	url: `/open/wechat/order/cancelOrderByConfirm/${orderId}`,

+ 1 - 1
pages/home/exchangeDetails.vue

@@ -9,7 +9,7 @@
                     <u--image shape="circle" width="80rpx" height="80rpx" :src="QaDetail.authorLogo" ></u--image>
                 </view>
                 <view class="wen_name">{{ QaDetail.authorName }}</view>
-                <view  class="follow" @click="setQacollect()">{{ QaDetail.isCollection == '2' ? '取消关注' : '关注问题' }}</view>
+                <view  class="follow" @click="setQacollect()">{{ QaDetail.isCollection == '1' ? '取消关注' : '关注问题' }}</view>
             </view>
             <view class="wdflex">
                 <!-- <view class="wen" style="background: #ff8c33">答</view> -->

+ 20 - 2
pages/market/ProductDetails.vue

@@ -109,9 +109,12 @@
                 <u--image width="48rpx" height="48rpx" :src="ProductDetails.favorites?'/static/market/iconm_shoucang.png':'/static/market/btn_shoucang.png'" ></u--image>
                 {{ProductDetails.favorites?'取消':'收藏'}}
             </view>
-            <view @click="openLink('market')" class="bm_item">
+            <view @click="openLink('market')" class="bm_item" style="position: relative">
                 <u--image width="48rpx" height="48rpx" src="/static/market/btn_gouwc.png" ></u--image>
                 购物车
+                <view class="gouwudot" v-if="shoppingCartTotal!=0" >
+                    {{ shoppingCartTotal }}
+                </view>
             </view>
             <view class="bm_btn">
                 <view @click="addShoppingCart()" class="bm_btn1">加入购物车</view>
@@ -172,7 +175,9 @@ return {
         author:'',
         score:5,
         content:''
-    }
+    },
+    shoppingCartTotal:0,
+    badgetype:'warning'
 }
 },
 async onLoad(e) {
@@ -184,6 +189,7 @@ async onLoad(e) {
         //获取评论列表
         await this.getreviewsPage()
     }
+    this.shoppingCartTotal = uni.getStorageSync('shoppingCartTotal')
     
 },
 methods: {
@@ -656,5 +662,17 @@ methods: {
     line-height: 72rpx;
     text-align: center;
 }
+.gouwudot{
+    position: absolute;
+    right: -8rpx;
+    color: #fff;
+    width: 32rpx;
+    height: 32rpx;
+    background: red;
+    font-size: 20rpx;
+    line-height: 32rpx;
+    border-radius: 50%;
+    text-align: center;
+}
 </style>
     

+ 3 - 5
pages/market/allOrder.vue

@@ -48,6 +48,7 @@
                 <view @click="linktoPublishComments()" v-if="item.type=='4'" class="btn">立即评价</view>
                 <view @click="toOrderAgain(item.id)" v-if="item.status=='3'||item.status=='2'" class="btn">再次购买</view> -->
 
+                <view @click="toCancelOrder(item.id)" v-if="item.status=='1'||item.status=='4'" class="btn">取消订单</view>
                 <view @click="reSubmitOrder(item)" v-if="item.status=='1'||item.status=='4'" class="btn">立即支付</view>
                 <view @click="toRefundApply(item.id)" v-if="item.status=='3'||item.status=='9'||item.status=='8'" class="btn">申请退款</view>
                 <view @click="toOrderAgain(item.id)" v-if="item.status=='7'||item.status=='-1'" class="btn">再次购买</view>
@@ -64,7 +65,7 @@
 </template>
 <script>
 import {orderPage,cancelOrder,orderAgain,payPaying,
-    confirmOrder,refundApply} from '@/http/api/common.js'
+    prePayOrder,refundApply} from '@/http/api/common.js'
 import * as util from '@/pages/util/util.js'
 export default {
 components: {
@@ -129,10 +130,7 @@ onReachBottom() {
 methods: {
     async reSubmitOrder(item){
         //立即支付
-        let res = await confirmOrder({
-            remark:item.remark,
-            deliveryAddressId:item.deliveryAddressId,
-        },item.id)
+        let res = await prePayOrder(item.id)
         if (res.data.code == 200) {
             let PaymentData = res.data.data
             const that = this;

+ 5 - 2
pages/market/confirmOrder.vue

@@ -112,7 +112,7 @@
 </template>
 <script>
 import {orderDetail,cancelOrderByConfirm,
-    confirmOrder,deliveryAddressList,
+    confirmOrder,deliveryAddressList,prePayOrder,
     payPaying} from '@/http/api/common.js'
 import * as util from '@/pages/util/util.js'
 export default {
@@ -199,7 +199,10 @@ methods: {
             deliveryAddressId:this.orderDetailData.deliveryAddressId,
         },this.orderDetailData.id)
         if (res.data.code == 200) {
-            let PaymentData = res.data.data
+            
+            let Payres = await prePayOrder(this.orderDetailData.id)
+            let PaymentData = Payres.data.data
+
             console.log('PaymentData',PaymentData);
             const that = this;
             // 调用微信支付

+ 12 - 0
pages/market/market.vue

@@ -204,6 +204,18 @@ methods: {
 						...v
 					}
 				})
+				let total = res.data.data.total || 0
+				uni.setStorageSync('shoppingCartTotal',total)
+				if (total != 0) {
+					uni.setTabBarBadge({
+						index: 3,
+						text: total+''
+					});
+				}else{
+					uni.hideTabBarRedDot({
+						index: 3,
+					});
+				}
 				//获取购物车后 自动计算一次
 				this.calcShoppingCart()
 			}

+ 95 - 3
pages/myinfo/myinfo.vue

@@ -56,11 +56,21 @@
           </view>
         </view>
     </view>
+    <view v-if="showGetwxinfo" class="wxinfo">
+        <view class='getwxinput'>
+            <input type='nickname' name='nickname' :value='userInfo.nickname' @blur="onchangenickname" placeholder="点击获取微信昵称" />
+        </view>
+
+        <button type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar">
+          点击获取头像
+        </button>
+
+        </view>
   </view>
 </template>
 
 <script>
-import {myInfo} from '@/http/api/common.js'
+import {myInfo,modifyInfo} from '@/http/api/common.js'
 export default {
   data() {
     return {
@@ -71,8 +81,13 @@ export default {
         qm:'无',
         orderCount:'0',
         isVendor:'0',
+        cartCount:'0',
         img:'https://cdn.uviewui.com/uview/album/1.jpg',
       },
+      userInfo:{
+          nickname:'',
+          avatar:''
+      },
       list:[
         {
           id:1,
@@ -111,7 +126,7 @@ export default {
           id:2,
           url:'/static/myinfo/icomx_gysrz.png',
           name:'供应商入驻',
-          linkto:'/supplierPagespages/supplier/SupplierEntryForm'
+          linkto:'/supplierPages/pages/supplier/SupplierEntryForm'
         },
         {
           id:3,
@@ -142,7 +157,8 @@ export default {
         //   url:'/static/myinfo/iconx_xitongg.png',
         //   name:'设置'
         // },
-      ]
+      ],
+      showGetwxinfo:false,
     }
   },
   onShow() {
@@ -154,14 +170,70 @@ export default {
   methods: {
     async getmyInfo(){
       let res = await myInfo()
+      console.log(res?.data?.data?.image);
+      if (!res.data.data.image || res.data.data.image == '') {
+        this.showGetwxinfo = true
+        return
+      }else{
+         this.showGetwxinfo = false
+      }
       if (res.data.code == 200) {
         this.myinfo.name = res.data.data.nickName
         this.myinfo.img = res.data.data.image
         this.myinfo.orderCount = res.data.data?.orderCount || 0
         this.myinfo.isVendor= res.data.data?.isVendor || 0
+        this.myinfo.cartCount = res.data.data?.cartCount || 0
+        
+        uni.setStorageSync('shoppingCartTotal',this.myinfo.cartCount)
+        if (this.myinfo.cartCount != 0) {
+          uni.setTabBarBadge({
+            index: 3,
+            text: this.myinfo.cartCount
+          });
+        }else{
+					uni.hideTabBarRedDot({
+						index: 3,
+					});
+				}
+        
         
       }
     },
+    onchangenickname(e){
+      this.userInfo.nickname = e.detail.value
+    },
+    async onChooseavatar(e) {	
+       
+        let avatarUrl = 'data:image/jpeg;base64,' +   uni.getFileSystemManager().readFileSync(e.detail.avatarUrl,'base64')
+
+        this.userInfo.avatar = avatarUrl
+        let res = await modifyInfo({
+            nickname:this.userInfo.nickname,
+            images:this.userInfo.avatar
+        })
+        if (res.data.code == 200) {
+          this.getmyInfo()
+        }
+        this.showGetwxinfo=false
+    },
+    uploadFilePromise(file) {
+        return new Promise((resolve, reject) => {
+            let a = uni.uploadFile({
+                url: env.BASEURL + '/open/upload/uploadFile', // 仅为示例,非真实的接口地址
+                filePath: file.url,
+                name: 'file',
+                success: (res) => {
+                    const fileData = JSON.parse(res.data)
+                    if (fileData.code == 500) {
+                        resolve('')
+                    }else{
+                        const fileData = JSON.parse(res.data)
+                        resolve(fileData.data.fileUrl)
+                    }
+                }
+            });
+        })
+    },
     tologin(){
       if(uni.getStorageSync('AppAuthorization')){
         //登录
@@ -306,4 +378,24 @@ export default {
   height: 100rpx;
   justify-content: space-between;
 }
+.getwxinput{
+  text-align: center;
+  margin: 20rpx 0;
+}
+.wxinfo{
+  position: fixed;
+    z-index: 10000;
+    top: 30vh;
+    width: 600rpx;
+    height: 330rpx;
+    left: 55rpx;
+    background: #e7e7e7;
+    border-radius: 10rpx;
+    padding: 20rpx;
+
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
 </style>