guhongwei 2 yıl önce
ebeveyn
işleme
ebc990f06d
5 değiştirilmiş dosya ile 262 ekleme ve 179 silme
  1. 5 1
      common/api.js
  2. 144 140
      manifest.json
  3. 13 3
      pages/index/index.vue
  4. 8 8
      pagesHome/market/type.vue
  5. 92 27
      pagesMy/address/index.vue

+ 5 - 1
common/api.js

@@ -4,17 +4,21 @@ const getDomain = (uri, method, type) => {
 	if (uri.startsWith('/wechat/api')) return config.serverUrl + uri;
 	else return config.serverUrl + '/point/v1/api' + uri;
 }
-export const requestBase = (uri, method, data, type) => {
+export const requestBase = (uri, method, data, type, token) => {
 	let baseUrl = getDomain(uri, method, type);
 	return new Promise((resolve, reject) => {
 		uni.request({
 			url: baseUrl,
 			method: method || 'GET',
 			data: data || {},
+			header: {
+				'token': token || ''
+			},
 			success: (res) => {
 				resolve(res.data);
 			},
 			fail: (err) => {
+				console.log(err);
 				uni.showToast({
 					title: '请求接口失败',
 					icon: 'fail'

+ 144 - 140
manifest.json

@@ -1,143 +1,147 @@
 {
-    "name" : "点到网",
-    "appid" : "__UNI__F7FD5DB",
-    "description" : "",
-    "versionName" : "1.0.0",
-    "versionCode" : "100",
-    "transformPx" : false,
-    /* 5+App特有相关 */
-    "app-plus" : {
-        "usingComponents" : true,
-        "nvueStyleCompiler" : "uni-app",
-        "compilerVersion" : 3,
-        "splashscreen" : {
-            "alwaysShowBeforeRender" : true,
-            "waiting" : true,
-            "autoclose" : true,
-            "delay" : 0
-        },
-        /* 模块配置 */
-        "modules" : {
-            "Geolocation" : {},
-            "OAuth" : {},
-            "Maps" : {}
-        },
-        /* 应用发布信息 */
-        "distribute" : {
-            /* android打包配置 */
-            "android" : {
-                "permissions" : [
-                    "<uses-feature android:name=\"android.hardware.camera\"/>",
-                    "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
-                    "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.CAMERA\"/>",
-                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
-                    "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
-                    "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
-                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
-                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
-                    "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
-                ]
-            },
-            /* ios打包配置 */
-            "ios" : {
-                "dSYMs" : false
-            },
-            /* SDK配置 */
-            "sdkConfigs" : {
-                "ad" : {},
-                "geolocation" : {
-                    "amap" : {
-                        "__platform__" : [ "ios", "android" ],
-                        "appkey_ios" : "",
-                        "appkey_android" : "82a18bf70282fb4b62ecec98b49be335"
-                    }
-                },
-                "oauth" : {
-                    "weixin" : {
-                        "appid" : "wx8cdd28824dfcdf19",
-                        "UniversalLinks" : ""
-                    }
-                },
-                "maps" : {}
-            },
-            "icons" : {
-                "android" : {
-                    "hdpi" : "unpackage/res/icons/72x72.png",
-                    "xhdpi" : "unpackage/res/icons/96x96.png",
-                    "xxhdpi" : "unpackage/res/icons/144x144.png",
-                    "xxxhdpi" : "unpackage/res/icons/192x192.png"
-                },
-                "ios" : {
-                    "appstore" : "unpackage/res/icons/1024x1024.png",
-                    "ipad" : {
-                        "app" : "unpackage/res/icons/76x76.png",
-                        "app@2x" : "unpackage/res/icons/152x152.png",
-                        "notification" : "unpackage/res/icons/20x20.png",
-                        "notification@2x" : "unpackage/res/icons/40x40.png",
-                        "proapp@2x" : "unpackage/res/icons/167x167.png",
-                        "settings" : "unpackage/res/icons/29x29.png",
-                        "settings@2x" : "unpackage/res/icons/58x58.png",
-                        "spotlight" : "unpackage/res/icons/40x40.png",
-                        "spotlight@2x" : "unpackage/res/icons/80x80.png"
-                    },
-                    "iphone" : {
-                        "app@2x" : "unpackage/res/icons/120x120.png",
-                        "app@3x" : "unpackage/res/icons/180x180.png",
-                        "notification@2x" : "unpackage/res/icons/40x40.png",
-                        "notification@3x" : "unpackage/res/icons/60x60.png",
-                        "settings@2x" : "unpackage/res/icons/58x58.png",
-                        "settings@3x" : "unpackage/res/icons/87x87.png",
-                        "spotlight@2x" : "unpackage/res/icons/80x80.png",
-                        "spotlight@3x" : "unpackage/res/icons/120x120.png"
-                    }
-                }
-            }
-        }
-    },
-    /* 快应用特有相关 */
-    "quickapp" : {},
-    /* 小程序特有相关 */
-    "mp-weixin" : {
-        "appid" : "wx8cdd28824dfcdf19",
-        "setting" : {
-            "urlCheck" : true,
-            "postcss" : true,
-            "minified" : true
-        },
-        "usingComponents" : true,
-        "optimization" : {
-            "subPackages" : true
-        },
-        "permission" : {
-            "scope.userLocation" : {
-                "desc" : "定位当前位置,选在收获地址"
-            }
-        },
+	"name": "点到网",
+	"appid": "__UNI__F7FD5DB",
+	"description": "",
+	"versionName": "1.0.0",
+	"versionCode": "100",
+	"transformPx": false,
+	/* 5+App特有相关 */
+	"app-plus": {
+		"usingComponents": true,
+		"nvueStyleCompiler": "uni-app",
+		"compilerVersion": 3,
+		"splashscreen": {
+			"alwaysShowBeforeRender": true,
+			"waiting": true,
+			"autoclose": true,
+			"delay": 0
+		},
+		/* 模块配置 */
+		"modules": {
+			"Geolocation": {},
+			"OAuth": {},
+			"Maps": {}
+		},
+		/* 应用发布信息 */
+		"distribute": {
+			/* android打包配置 */
+			"android": {
+				"permissions": [
+					"<uses-feature android:name=\"android.hardware.camera\"/>",
+					"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
+					"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
+					"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+					"<uses-permission android:name=\"android.permission.CAMERA\"/>",
+					"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
+					"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
+					"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
+					"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
+					"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
+					"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
+					"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
+					"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
+					"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
+					"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
+					"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
+				]
+			},
+			/* ios打包配置 */
+			"ios": {
+				"dSYMs": false
+			},
+			/* SDK配置 */
+			"sdkConfigs": {
+				"ad": {},
+				"geolocation": {
+					"amap": {
+						"__platform__": ["ios", "android"],
+						"appkey_ios": "",
+						"appkey_android": "82a18bf70282fb4b62ecec98b49be335"
+					}
+				},
+				"oauth": {
+					"weixin": {
+						"appid": "wx8cdd28824dfcdf19",
+						"UniversalLinks": ""
+					}
+				},
+				"maps": {}
+			},
+			"icons": {
+				"android": {
+					"hdpi": "unpackage/res/icons/72x72.png",
+					"xhdpi": "unpackage/res/icons/96x96.png",
+					"xxhdpi": "unpackage/res/icons/144x144.png",
+					"xxxhdpi": "unpackage/res/icons/192x192.png"
+				},
+				"ios": {
+					"appstore": "unpackage/res/icons/1024x1024.png",
+					"ipad": {
+						"app": "unpackage/res/icons/76x76.png",
+						"app@2x": "unpackage/res/icons/152x152.png",
+						"notification": "unpackage/res/icons/20x20.png",
+						"notification@2x": "unpackage/res/icons/40x40.png",
+						"proapp@2x": "unpackage/res/icons/167x167.png",
+						"settings": "unpackage/res/icons/29x29.png",
+						"settings@2x": "unpackage/res/icons/58x58.png",
+						"spotlight": "unpackage/res/icons/40x40.png",
+						"spotlight@2x": "unpackage/res/icons/80x80.png"
+					},
+					"iphone": {
+						"app@2x": "unpackage/res/icons/120x120.png",
+						"app@3x": "unpackage/res/icons/180x180.png",
+						"notification@2x": "unpackage/res/icons/40x40.png",
+						"notification@3x": "unpackage/res/icons/60x60.png",
+						"settings@2x": "unpackage/res/icons/58x58.png",
+						"settings@3x": "unpackage/res/icons/87x87.png",
+						"spotlight@2x": "unpackage/res/icons/80x80.png",
+						"spotlight@3x": "unpackage/res/icons/120x120.png"
+					}
+				}
+			}
+		}
+	},
+	/* 快应用特有相关 */
+	"quickapp": {},
+	/* 小程序特有相关 */
+	"mp-weixin": {
+		"appid": "wx8cdd28824dfcdf19",
+		"setting": {
+			"urlCheck": true,
+			"postcss": true,
+			"minified": true
+		},
+		"usingComponents": true,
+		"optimization": {
+			"subPackages": true
+		},
+		"permission": {
+			"scope.userLocation": {
+				"desc": "定位当前位置,选在收获地址"
+			}
+		},
+		"requiredPrivateInfos": [
+			"chooseAddress"
+		],
 		"plugins": {
-		        "chooseLocation": {
-		        "version": "1.0.9",
-		        "provider": "wx76a9a06e5b4e693e"
-		        }
-		    }
-    },
-    "mp-alipay" : {
-        "usingComponents" : true
-    },
-    "mp-baidu" : {
-        "usingComponents" : true
-    },
-    "mp-toutiao" : {
-        "usingComponents" : true
-    },
-    "uniStatistics" : {
-        "enable" : false
-    },
-    "vueVersion" : "2"
+			"chooseLocation": {
+				"version": "1.0.9",
+				"provider": "wx76a9a06e5b4e693e"
+			}
+		}
+
+	},
+	"mp-alipay": {
+		"usingComponents": true
+	},
+	"mp-baidu": {
+		"usingComponents": true
+	},
+	"mp-toutiao": {
+		"usingComponents": true
+	},
+	"uniStatistics": {
+		"enable": false
+	},
+	"vueVersion": "2"
 }

+ 13 - 3
pages/index/index.vue

@@ -39,6 +39,19 @@
 				});
 			},
 			watchLogin() {
+				uni.getSystemInfo({
+					success: async function(res) {
+						uni.setStorage({
+							key: 'system',
+							data: res,
+							success: function() {
+								uni.redirectTo({
+									url: `/pages/home/index`
+								})
+							}
+						});
+					}
+				});
 				// const key = '5WLBZ-H6RWU-NQVVO-BQG7I-XEHFK-PAFSF'; //使用在腾讯位置服务申请的key
 				// const referer = 'test'; //调用插件的app的名称
 				// const location = JSON.stringify({
@@ -50,9 +63,6 @@
 				// uni.navigateTo({
 				// 	url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer + '&location=' + location + '&category=' + category
 				// });
-				uni.redirectTo({
-					url: `/pages/home/index`
-				})
 			},
 		}
 	}

+ 8 - 8
pagesHome/market/type.vue

@@ -40,7 +40,6 @@
 
 <script>
 	export default {
-		name: 'type',
 		data() {
 			return {
 				active: '0',
@@ -81,14 +80,15 @@
 				if (res.errcode == '0' && res.data.length > 0) {
 					that.$set(that, `list`, res.data[0].children)
 				}
-			}
-		},
-		// 公共跳转
-		toCommon(e) {
-			uni.navigateTo({
-				url: `/${e}`
-			})
+			},
+			// 公共跳转
+			toCommon(e) {
+				uni.navigateTo({
+					url: `/${e}`
+				})
+			},
 		},
+
 	}
 </script>
 

+ 92 - 27
pagesMy/address/index.vue

@@ -36,7 +36,7 @@
 			</view>
 			<view class="two">
 				<view class="two_1">
-					<button type="default">获取微信地址</button>
+					<button type="default" @click="toWxaddress()">获取微信地址</button>
 				</view>
 				<view class="two_1">
 					<button type="default" @click="toCommon()">新增收货地址</button>
@@ -50,38 +50,103 @@
 	export default {
 		data() {
 			return {
-				list: [ //信息列表
-					{
-						id: '1234567',
-						name: '姓名',
-						phone: '13174420325',
-						province: '吉林省',
-						city: '长春市',
-						area: '朝阳区',
-						address: '详细地址',
-						number: 0,
-						is_default: false
-					},
-					{
-						id: '123456',
-						name: '姓名',
-						phone: '13174420325',
-						province: '吉林省',
-						city: '长春市',
-						area: '朝阳区',
-						address: '详细地址',
-						number: 11,
-						is_default: true
-					}
-
-				]
+				user: {},
+				list: [],
+				total: 0,
+				skip: 0,
+				limit: 5,
+				page: 0
 			};
 		},
-		onShow: function() {},
+		onShow: function() {
+			const that = this;
+			that.watchLogin()
+		},
 		methods: {
+			// 监听用户是否登录
+			watchLogin() {
+				const that = this;
+				uni.getStorage({
+					key: 'token',
+					success: function(res) {
+						let user = that.$jwt(res.data);
+						that.$set(that, `user`, user);
+						that.search()
+					},
+					fail: function(err) {
+						uni.reLaunch({
+							url: `/pages/login/index`
+						})
+					}
+				})
+			},
+			// 查询列表
+			async search() {
+				const that = this;
+				let user = that.user;
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					customer: user._id
+				}
+				const res = await that.$api(`/address`, 'GET', {
+					...info
+				})
+				if (res.errcode == '0') {
+					let list = [...that.list, ...res.data];
+					that.$set(that, `list`, list);
+					that.$set(that, `total`, res.total)
+				}
+			},
 			// 分页
 			toPage() {
 
+			},
+			// 获取微信地址
+			toWxaddress() {
+				const that = this;
+				let user = that.user;
+				uni.getStorage({
+					key: 'system',
+					success: function(res) {
+						if (res.data.uniPlatform == 'app') {
+							uni.showToast({
+								title: '请进入微信小程序进行获取微信地址',
+								icon: 'none'
+							})
+						} else if (res.data.uniPlatform == 'mp-weixin') {
+							uni.chooseAddress({
+								success: async function(add) {
+									let params = {
+										customer: user._id,
+										name: add.userName,
+										phone: add.telNumber,
+										province: add.provinceName,
+										city: add.cityName,
+										area: add.countyName,
+										address: add.detailInfo
+									}
+									const arr = await that.$api(`/address`, 'POST', params);
+									if (arr.errcode == '0') {
+										uni.showToast({
+											title: '添加收货地址成功',
+											icon: 'none'
+										})
+										that.search()
+									} else {
+										uni.showToast({
+											title: arr.errmsg,
+											icon: 'none'
+										})
+									}
+								},
+								fail: function(err) {
+									console.log(err);
+								}
+							})
+						}
+					}
+				})
 			},
 			// 设置默认
 			toDefa(e) {