shish 3 лет назад
Родитель
Сommit
cfb7acea04

+ 1 - 3
hdApp/src/components/plugin/simple-address.vue

@@ -56,9 +56,7 @@
 // import provinceData from './city-data/province.js'
 // import cityData from './city-data/city.js'
 // import areaData from './city-data/area.js'
-import {
-  regionTree
-} from "@/api/official";
+import { regionTree } from "@/api/official";
 export default {
 	name: 'simpleAddress',
 	props: {

+ 8 - 0
mallApp/src/api/user/index.js

@@ -1,5 +1,13 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
+export const updateInfo = data => {
+	return https.post('/user/update', data)
+}
+
+export const currentInfo = data => {
+	return https.get('/user/current-info', data)
+}
+
 export const recentShop = data => {
 	return https.get('/user/recent-shop', data)
 }

+ 7 - 0
mallApp/src/components/plugin/simple-address.vue

@@ -56,6 +56,7 @@
 // import provinceData from './city-data/province.js'
 // import cityData from './city-data/city.js'
 // import areaData from './city-data/area.js'
+import { regionTree } from "@/api/official"
 export default {
 	name: 'simpleAddress',
 	props: {
@@ -125,7 +126,13 @@ export default {
 		this.sInit()
 	},
 	methods: {
+		_regionTree() {
+			regionTree().then(res => {
+				this.region = res.data.tree;
+			});
+		},
 		sInit() {
+			this._regionTree()
 		// 	this.handPickValueDefault() // 对 pickerValueDefault 做兼容处理
 		// 	this.provinceDataList = JSON.parse(JSON.stringify(this.region))
 		// 	this.cityDataList = []

+ 1 - 3
mallApp/src/mixins/cgProduct.js

@@ -322,10 +322,8 @@ export default {
 				this.scrollPushList();
 			} catch (error) {
 				console.log(error)
-				console.log(33344)
 			} finally {
-				uni.hideLoading();
-				console.log(33355)
+				uni.hideLoading()
 			}
 		},
 		/**

+ 2 - 1
mallApp/src/pages.json

@@ -15,7 +15,8 @@
             "root": "pages/user",
             "pages": [
                 { "path": "register", "style": { "navigationBarTitleText": "注册" } },
-                { "path": "password", "style": { "navigationBarTitleText": "修改密码" } }
+                { "path": "password", "style": { "navigationBarTitleText": "修改密码" } },
+                { "path": "modify", "style": { "navigationBarTitleText": "资料修改" } }
             ]
         },
         {

+ 21 - 6
mallApp/src/pages/billing/affirmGhs.vue

@@ -57,9 +57,9 @@
 
 					<tui-list-cell class="line-cell" :hover="false" :arrow="true" v-if="form.sendType == 2" @click="modifyAddress">
 						<view class="tui-title">收花地址</view>
-						<view v-if="!$util.isEmpty(shopInfo.lat) && !$util.isEmpty(shopInfo.long)">
-							<view><text>{{shopInfo.fullAddress}}</text></view>
-							<view><text>{{shopInfo.showAddress}}</text></view>
+						<view v-if="!$util.isEmpty(userInfo.lat) && !$util.isEmpty(userInfo.long)">
+							<view><text>{{userInfo.fullAddress}}</text></view>
+							<view><text>{{userInfo.showAddress}}</text></view>
 						</view>
 						<view v-else>
 							<view><text style="color:#CCCCCC;">请完善地址</text></view>
@@ -106,6 +106,7 @@
 import TuiListCell from "@/components/plugin/list-cell";
 import productMins from "@/mixins/cgProduct";
 import { buyItem,freight } from "@/api/order"
+import { currentInfo } from "@/api/user"
 import { mapActions, mapGetters } from "vuex";
 export default {
 	name: "BillingAffirm",
@@ -144,7 +145,7 @@ export default {
 			today:'',
 			monthLater:'',
 			modifyPrice:0,
-			shopInfo:{
+			userInfo:{
 				lat:'',
 				long:'',
 				fullAddress:'',
@@ -173,7 +174,6 @@ export default {
 			}
 		}
 		this.list = list
-		this.calcFreight()
 		this.calcPrice()
 	},
 	computed: {
@@ -183,6 +183,17 @@ export default {
 		...mapActions(["initMerchantInfo"]),
 		init(){
 			this.calcFreight()
+
+			currentInfo().then(res=>{
+				let that = this
+				if(res.code == 1){
+					that.userInfo = res.data.info
+				}
+			})
+
+		},
+		modifyAddress(){
+      		this.$util.pageTo({ url: '/pages/user/modify'})
 		},
 		changeSendType(num){
 			this.form.sendType = num
@@ -233,7 +244,11 @@ export default {
 				}
 				return { productId: ele.id, num:num,ptItemId:ele.itemId,property:1,unitType:unitType,property:1};
 			});
-			let params = { product: JSON.stringify(product) }
+			let params = { product: JSON.stringify(product),sendType:that.form.sendType }
+			if(this.$util.isEmpty(this.userInfo.lat) || this.$util.isEmpty(this.userInfo.long)){
+				this.$msg('请完善地址')
+				return false
+			}
 			uni.showLoading({mask:true})
 			buyItem(params).then(res => {
 				uni.hideLoading()

+ 200 - 0
mallApp/src/pages/user/modify.vue

@@ -0,0 +1,200 @@
+<template>
+	<view class="app-content">
+		<form @submit="formSubmit" @reset="formReset">
+			<view class="module-com input-line-wrap">
+				<tui-list-cell class="line-cell" :hover="false">
+					<view class="tui-title">名称</view>
+					<input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请输入名称" maxlength="50" type="text" />
+				</tui-list-cell>
+				<tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="openAddres">
+					<view class="tui-title">所在城市</view>
+					<view class="tui-input" v-if="form.province || form.city">{{ form.province + '-' + form.city }}</view>
+					<view class="tui-placeholder" v-else>请选择</view>
+					<input v-model="form.province" name="province" hidden />
+				</tui-list-cell>
+				<tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="selectRegion">
+					<view class="tui-title">所在地址</view>
+					<view class="tui-input" v-if="form.address">{{ form.address }}</view>
+					<view class="tui-placeholder" v-else>请填写详细地址</view>
+					<input v-model="form.address" name="address" hidden />
+				</tui-list-cell>
+				<tui-list-cell class="line-cell" :hover="false">
+					<view class="tui-title ">门牌号</view>
+					<input v-model="form.floor" placeholder-class="phcolor" class="tui-input" name="floor" placeholder="楼号门牌号(选填)" />
+				</tui-list-cell>
+			</view>
+			<view class="confirm-btn">
+				<button class="admin-button-com big blue" formType="submit">修改</button>
+			</view>
+		</form>
+		<!-- 省市联动 -->
+		<simple-address ref="simpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onCityConfirm"></simple-address>
+		<!-- 选择地区 -->
+		<app-area-sel :show.sync="showRegion" :city="form.city" @change="changeAreaFn" />
+	</view>
+</template>
+<script>
+import TuiListCell from '@/components/plugin/list-cell'
+import SimpleAddress from '@/components/plugin/simple-address'
+import AppAreaSel from '@/components/app-area-sel'
+const form = require('@/utils/formValidation.js')
+import {mapActions} from "vuex";
+import {currentInfo,updateInfo} from "@/api/user"
+export default {
+	name: 'modify',
+	components: {
+		TuiListCell,
+		SimpleAddress,
+		AppAreaSel
+	},
+	data() {
+		return {
+			form: {
+				name: '',
+				province: '',
+				city: '',
+				address: '',
+				showAddress:'',
+				floor: '',
+			},
+			showRegion: false,
+			region: {
+				lat: 0,
+				long: 0
+			},
+			regionData: [],
+			cityPickerValueDefault: [0, 0]
+		}
+	},
+	onLoad() {
+		this.getUserInfo()
+	},
+	methods: {
+		init() {
+
+		},
+		getUserInfo() {
+            currentInfo().then(res=>{
+                let data = res.data.info
+                if (this.$util.isEmpty(data)){
+                    return
+                } 
+                Object.keys(this.form).forEach((i, index) => {
+                    this.form[i] = data[i]
+                })
+                this.region.lat = data.lat
+                this.region.long = data.long
+            })
+		},
+		selectRegion() {
+			if (!this.form.city) {
+				this.$msg('请先选择城市!')
+				return false
+			}
+			this.showRegion = true
+		},
+		changeAreaFn(e) {
+			this.form.address = e.title
+			this.region.lat = e.location.lat
+			this.region.long = e.location.lng
+			this.form.showAddress = e.address
+		},
+		openAddres() {
+			this.$refs.simpleAddress.open()
+		},
+		onCityConfirm(e) {
+			this.form.province = e.provinceName
+			this.form.city = e.cityName
+			this.form.address = ''
+			this.region.lat = 0
+			this.region.long = 0
+		},
+		confirmFn() {
+
+			if (this.option.id) {
+				this.form.id = this.option.id
+			}
+			this.form = {...this.form,...this.region}
+			uni.showLoading({mask:true})
+			updateInfo(this.form).then(res => {
+				uni.hideLoading()
+
+				uni.navigateBack({})
+
+			})
+		},
+		formSubmit(e) {
+			let rules = [
+				{
+					name: 'name',
+					rule: ['required'],
+					msg: ['请输入名称']
+				},
+				{
+					name: 'province',
+					rule: ['required'],
+					msg: ['请选择地址']
+				},
+				{
+					name: 'address',
+					rule: ['required'],
+					msg: ['请填写详细地址']
+				}
+			]
+			let formData = e.detail.value
+			let checkRes = form.validation(formData, rules)
+			if (!checkRes) {
+				this.confirmFn()
+			} else {
+				this.$msg(checkRes)
+			}
+		}
+	}
+}
+</script>
+
+<style lang="scss" scoped>
+	.app-content {
+		min-height: calc(100vh - 20upx);
+		padding-top: 20upx;
+		padding-bottom:130upx;
+	}
+	.prompt-text {
+		color: $fontColor3;
+		padding-left: 30upx;
+		margin-bottom: 30upx;
+	}
+	.module-com {
+		margin-bottom: 20upx;
+		  background-color: #fff;
+		.member-wrap {
+			.member-det {
+				font-size: 24upx;
+				margin-left: 20upx;
+			}
+		}
+		.remark-wrap {
+			align-items: flex-start;
+			.remark {
+				height: 100upx;
+			}
+		}
+		.module-tit {
+			padding: 20upx 30upx;
+			font-size: 28upx;
+		}
+		.module-det {
+			padding: 0 30upx;
+		}
+	}
+	.confirm-btn {
+		position:fixed;
+		bottom:0upx;
+		width: calc(100% - 60upx);
+		margin: 60upx 30upx 0upx;
+		z-index:99;
+		.admin-button-com {
+			width: 100%;
+		}
+	}
+</style>