Bläddra i källkod

feat:获取微信收货地址

DaMowang 3 år sedan
förälder
incheckning
c650335a7e

+ 14 - 1
src/components/authorize-module/index.vue

@@ -28,7 +28,8 @@
 				<view class="btnBar flex_r flex_ac flex_jb">
 					<button class='no-authorize_btn unSetBtn' @tap="onSoHAuth">{{isGetTel ? "暂不授权" : "暂不登录"}}</button>
 					<button open-type="getPhoneNumber" class='no-authorize_btn' @getphonenumber="onGotPhoneNumber" lang="zh_CN" v-if="!isGetUserInfo">立即登录</button>
-					<button open-type="getUserInfo" class='no-authorize_btn' @getuserinfo="onGotUserInfo" lang="zh_CN" v-else>获取用户信息</button>
+					<!-- <button open-type="getUserInfo" class='no-authorize_btn' @getuserinfo="onGotUserInfo" lang="zh_CN" v-else>获取用户信息</button> -->
+                    <button  @tap="getUserProfile" v-else> 获取头像昵称 </button>
 					<!-- <button open-type="getUserInfo" class='no-authorize_btn' @tap="onGotUserInfo" lang="zh_CN">立即登录</button> -->
 				</view>
 			</view>
@@ -87,6 +88,18 @@
 			    var value = e.detail.value;
 			    this.isDisabled = value.length == 0
 			},
+            getUserProfile(e) {
+                // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
+                // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
+                uni.getUserProfile({
+                    desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+                    success: (res) => {
+                        console.log("==============================");
+                        console.log(res);
+                        console.log("==============================");
+                    }
+                })
+            },
 		}
 	}
 </script>

+ 57 - 52
src/manifest.json

@@ -1,28 +1,28 @@
 {
-    "name" : "一茶酒社",
-    "appid" : "__UNI__95AE405",
-    "description" : "",
-    "versionName" : "1.0.0",
-    "versionCode" : "100",
-    "transformPx" : false,
+    "name": "一茶酒社",
+    "appid": "__UNI__95AE405",
+    "description": "",
+    "versionName": "1.0.0",
+    "versionCode": "100",
+    "transformPx": false,
     /* 5+App特有相关 */
-    "app-plus" : {
-        "usingComponents" : true,
-        "nvueCompiler" : "uni-app",
-        "compilerVersion" : 3,
-        "splashscreen" : {
-            "alwaysShowBeforeRender" : true,
-            "waiting" : true,
-            "autoclose" : true,
-            "delay" : 0
+    "app-plus": {
+        "usingComponents": true,
+        "nvueCompiler": "uni-app",
+        "compilerVersion": 3,
+        "splashscreen": {
+            "alwaysShowBeforeRender": true,
+            "waiting": true,
+            "autoclose": true,
+            "delay": 0
         },
         /* 模块配置 */
-        "modules" : {},
+        "modules": {},
         /* 应用发布信息 */
-        "distribute" : {
+        "distribute": {
             /* android打包配置 */
-            "android" : {
-                "permissions" : [
+            "android": {
+                "permissions": [
                     "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
                     "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
@@ -48,57 +48,62 @@
                 ]
             },
             /* ios打包配置 */
-            "ios" : {},
+            "ios": {},
             /* SDK配置 */
-            "sdkConfigs" : {}
+            "sdkConfigs": {}
         }
     },
     /* 快应用特有相关 */
-    "quickapp" : {},
+    "quickapp": {},
     /* 小程序特有相关 */
-    "mp-weixin" : {
-        "appid" : "wx8ebee994ea7c5af3",
-        "setting" : {
-            "urlCheck" : false,
-            "es6" : true,
-            "postcss" : false,
-            "minified" : true
+    "mp-weixin": {
+        "appid": "wx8ebee994ea7c5af3",
+        "setting": {
+            "urlCheck": false,
+            "es6": true,
+            "postcss": false,
+            "minified": true
         },
-        "usingComponents" : true,
-        "permission" : {}
+        "usingComponents": true,
+        "permission": {},
+        "requiredPrivateInfos": [
+            "chooseLocation",
+            "getLocation",
+            "chooseAddress"
+        ]
     },
-    "mp-alipay" : {
-        "usingComponents" : true,
-        "uniStatistics" : {
-            "enable" : false
+    "mp-alipay": {
+        "usingComponents": true,
+        "uniStatistics": {
+            "enable": false
         }
     },
-    "mp-baidu" : {
-        "usingComponents" : true
+    "mp-baidu": {
+        "usingComponents": true
     },
-    "mp-toutiao" : {
-        "usingComponents" : true
+    "mp-toutiao": {
+        "usingComponents": true
     },
-    "uniStatistics" : {
-        "enable" : false
+    "uniStatistics": {
+        "enable": false
     },
-    "h5" : {
+    "h5": {
         // "devServer": {
         // 	"host": "h5.wmzx.com",
         // 	"port": 80
         // },
-        "template" : "index.html",
-        "router" : {
-            "mode" : "history",
-            "base" : ""
+        "template": "index.html",
+        "router": {
+            "mode": "history",
+            "base": ""
         },
-        "optimization" : {
-            "treeShaking" : {
-                "enable" : true
+        "optimization": {
+            "treeShaking": {
+                "enable": true
             }
         },
-        "devServer" : {
-            "https" : false
+        "devServer": {
+            "https": false
         }
     }
-}
+}

+ 7 - 8
src/pages/index/index.vue

@@ -98,7 +98,7 @@ export default {
         };
     },
     onLoad(option) {
-        },
+    },
     onLaunch() {},
     onShow() {
         this.loadData()
@@ -135,7 +135,6 @@ export default {
         // 获取公告列表
         getAnnounce() {
             post("notice").then((res) => {
-                console.log(res);
                 if (res.code === 0) {
                     this.not_list = [res.data.data];
                 }
@@ -172,12 +171,12 @@ export default {
             }else if(item.type == 2){
                 this.goto('/pages/product/productWholesale',{type:item.type})
             }
-            // else if(item.type == 3){
-            //     this.goto('/pages/product/productRetail',{type:item.type})
-            // }
-            // else if(item.type == 4){
-            //     this.goto('/pages/product/productRetail',{type:item.type})
-            // }
+            else if(item.type == 3){
+                this.goto('/pages/product/productRetail',{type:item.type})
+            }
+            else if(item.type == 4){
+                this.goto('/pages/product/productRetail',{type:item.type})
+            }
             else{
                 appEv.errTips('此功能暂未开放!')
                 return false

+ 2 - 1
src/pages/sign/index.vue

@@ -211,9 +211,10 @@ export default {
                 type: 3
             }
             post("goods/goodsList", data).then(res => {
+                console.log(page);
                 if (res.code === 0) {
                     let obj = res.data.data
-                    if(page == 1) that.goods = []
+                    if(page <= 1) that.goods = []
                     if (obj.length > 0) {
                         obj.forEach(e => {
                             that.goods.push(e)

+ 27 - 0
src/pages/to-pay-list/index.vue

@@ -159,12 +159,39 @@ export default {
                             break;
                         } else this.DefaultAddress = da[0]
                     }
+                    // #ifdef  MP-WEIXIN
+                    if(!da.length) this.getwexinAddress()
+                    // #endif
                 }
             })
         },
+        //获取微信的收货地址
+        getwexinAddress(){
+            uni.chooseAddress({
+                success(res) {
+                    if(res.errMsg == "chooseAddress:ok"){
+                        let data = {
+                            address: res.provinceName + res.cityName + res.countyName + res.detailInfo,
+                            mobile: res.telNumber,
+                            name: res.userName,
+                            is_default: 0
+                        }
+                        post("user/addAddress", data).then(res => {
+                            if (res.code === 0) {
+                                appEv.errTips(res.msg);
+                                this.loadAddress();
+                            }
+                        })
+                    }
+                }
+            })
+        },
+
         chooseWXaddress(va) {
+            // this.getwexinAddress()
             let a = va != "add" ? this.DefaultAddress.id : 'add'
             this.$refs.userAddress.open(a);
+
             // this.goto("/pages/xghc-addrress/userAddress");
         },
         // 支付