完成3.0功能升级

This commit is contained in:
Gao xiaosong
2020-07-12 22:44:37 +08:00
parent 34565e6bf4
commit e8240a54a7
58 changed files with 1916 additions and 15048 deletions

View File

@ -1,57 +1,24 @@
<template>
<view class="personal-data">
<view class="wrapper">
<view class="title">管理我的账号</view>
<view class="wrapList">
<view
class="item acea-row row-between-wrapper"
:class="item.uid === userInfo.uid ? 'on' : ''"
v-for="(item, switchUserInfoIndex) in switchUserInfo"
:key="switchUserInfoIndex"
>
<view class="item acea-row row-between-wrapper on">
<view class="picTxt acea-row row-between-wrapper">
<view class="pictrue">
<!-- <VueCoreImageUpload
class="btn btn-primary"
:crop="false"
compress="80"
@imageuploaded="imageuploaded"
:headers="headers"
:max-file-size="5242880"
:credentials="false"
inputAccept="image/*"
inputOfFile="file"
:url="url"
ref="upImg"
v-if="item.uid === userInfo.uid"
>
<view class="pictrue">
<image :src="item.avatar" />
</view>
</VueCoreImageUpload>-->
<!-- <view class="pictrue" v-else>
<image :src="item.avatar" />
</view>-->
<image
src="@/static/images/alter.png"
class="alter"
v-if="item.uid === userInfo.uid"
/>
<view class="pictrue" @tap="chooseImage">
<div class="pictrue">
<img :src="avatar" />
</div>
<image src="@/static/images/alter.png" class="alter" />
</view>
<view class="text">
<view class="name line1">{{ item.nickname }}</view>
<view class="phone">绑定手机号{{ item.phone }}</view>
<view class="name line1">{{ userInfo.nickname }}</view>
<view class="phone">
绑定手机号
<text v-if="userInfo.phone">{{ userInfo.phone }}</text>
<text v-else>未绑定</text>
</view>
</view>
</view>
<view
class="currentBnt acea-row row-center-wrapper font-color-red"
v-if="item.uid === userInfo.uid"
>当前账号</view>
<view
class="bnt font-color-red acea-row row-center-wrapper"
v-else
@click="switchAccounts(index)"
>使用账号</view>
</view>
</view>
</view>
@ -82,23 +49,26 @@
<text>点击修改密码</text>
<text class="iconfont icon-suozi"></text>
</view>
</view> -->
</view>-->
</view>
<!--<view class="modifyBnt bg-color-red" @click="submit">保存修改</view>-->
<!-- <view
<view class="modifyBnt bg-color-red" @click="submit">保存修改</view>
<view
class="logOut cart-color acea-row row-center-wrapper"
@click="logout"
v-if="!isWeixin"
>
退出登录
</view>-->
v-if="$deviceType=='app'"
>退出登录</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import { trim, isWeixin } from "@/utils";
import { trim, isWeixin, chooseImage } from "@/utils";
import { VUE_APP_API_URL } from "@/config";
import { postUserEdit, getLogout, switchH5Login, getUser } from "@/api/user";
import {
postUserEdit,
getLogout,
switchH5Login,
getUserInfo
} from "@/api/user";
import cookie from "@/utils/store/cookie";
import store from "@//store";
import dayjs from "dayjs";
@ -110,10 +80,6 @@ export default {
},
data: function() {
return {
url: `${VUE_APP_API_URL}/upload/image`,
headers: {
Authorization: "Bearer " + this.$store.state.token
},
avatar: "",
isWeixin: false,
currentAccounts: 0,
@ -156,7 +122,8 @@ export default {
.catch(err => {
uni.hideLoading();
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
title:
err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
@ -170,7 +137,7 @@ export default {
},
getUserInfo: function() {
let that = this;
getUser().then(res => {
getUserInfo().then(res => {
// let switchUserInfo = res.data.switchUserInfo;
// for (let i = 0; i < switchUserInfo.length; i++) {
// if (switchUserInfo[i].uid == that.userInfo.uid) that.userIndex = i;
@ -184,24 +151,18 @@ export default {
// that.$set(this, "switchUserInfo", switchUserInfo);
});
},
imageuploaded(res) {
if (res.status !== 200) {
uni.showToast({
title: res.msg || res.response.data.msg,
icon: "none",
duration: 2000
});
return;
}
if (this.switchUserInfo[this.userIndex] === undefined) return;
this.$set(this.switchUserInfo[this.userIndex], "avatar", res.data.url);
chooseImage() {
chooseImage(img => {
console.log(img)
this.avatar = img;
});
},
submit: function() {
let userInfo = this.switchUserInfo[this.userIndex];
let userInfo = this.userInfo;
postUserEdit({
nickname: trim(this.userInfo.nickname),
avatar: userInfo.avatar
avatar: this.avatar
}).then(
res => {
this.$store.dispatch("userInfo", true);
@ -214,7 +175,8 @@ export default {
},
err => {
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
title:
err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
@ -230,8 +192,10 @@ export default {
getLogout()
.then(res => {
this.$store.commit("logout");
clearAuthStatus();
location.href = location.origin;
this.$yrouter.replace({
path: "/pages/user/Login/index",
query: {}
});
})
.catch(err => {});
} else if (res.cancel) {

View File

@ -117,11 +117,7 @@
<view class="myService">
<view class="serviceList acea-row row-middle">
<template v-for="(item, MyMenusIndex) in MyMenus">
<view
class="item"
:key="MyMenusIndex"
@click="goPages(MyMenusIndex)"
>
<view class="item" :key="MyMenusIndex" @click="goPages(MyMenusIndex)">
<view class="pictrue">
<image :src="item.pic" />
</view>
@ -133,19 +129,9 @@
<view class="pictrue"></view>
<view class="cell">hexiao</view>
<text class="iconfont icon-jiantou"></text>
</view> -->
</view>-->
</view>
</view>
<!--<view -->
<!--class="item"-->
<!--@click="changeswitch(true)"-->
<!--v-if="userInfo.phone && isWeixin"-->
<!--&gt;-->
<!--<view class="pictrue"><image src="@/static/images/switch.png" /></view>-->
<!--<view>账号切换</!--<view>-->
<!--</!--<view>-->
<!-- </view>
</view>-->
</view>
<view class="by">
<view>
@ -163,7 +149,7 @@
</template>
<script>
import { mapState, mapGetters, mapMutations, mapActions } from "vuex";
import { getUser, getMenuUser, bindingPhone } from "@/api/user";
import { getUserInfo, getMenuUser, bindingPhone } from "@/api/user";
import { isWeixin, VUE_APP_RESOURCES_URL } from "@/utils";
import SwitchWindow from "@/components/SwitchWindow";
import Authorization from "@/pages/authorization/index";
@ -283,7 +269,7 @@ export default {
},
User: function() {
let that = this;
getUser().then(res => {
getUserInfo().then(res => {
that.user = res.data;
that.orderStatusNum = res.data.orderStatusNum;
});

View File

@ -12,29 +12,13 @@
<view class="item acea-row row-between-wrapper">
<view class="name">所在地区</view>
<view class="picker acea-row row-between-wrapper select-value form-control">
<view class="address" @tap="openAddres">
<!-- <picker
@columnchange="addRessColumnchange"
@change="changeAddress"
range-key="name"
mode="multiSelector"
:range="district"
>
<text class="uni-input" v-if="model2">{{model2}}</text>
<text class="uni-input" v-else>请选择地区</text>
</picker>-->
<text class="uni-input">{{model2||'请选择'}}</text>
<simple-address
ref="simpleAddress"
:pickerValueDefault="cityPickerValueDefault"
@onConfirm="onConfirm"
themeColor="#007AFF"
></simple-address>
<!-- <view slot="right" @click.stop="show2 = true">{{ model2 || "请选择收货地址" }}</view> -->
<!-- <vant-popup :show="show2" position="bottom" @close="closeaArea">
<vant-area :area-list="district" columns-num="3" :columns-placeholder="['请选择', '请选择', '请选择']" title="请选择"
@confirm="result2" />
</vant-popup>-->
<view class="address">
<CitySelect
ref="cityselect"
:defaultValue="addressText"
@callback="result"
:items="district"
></CitySelect>
</view>
<view class="iconfont icon-dizhi font-color-red"></view>
</view>
@ -57,92 +41,63 @@
</view>
</view>
<view></view>
<view class="keepBnt bg-color-red" @click="submit">立即保存</view>
<view class="keepBnt bg-color-red" @tap="submit">立即保存</view>
<view class="wechatAddress" v-if="isWechat && !id" @click="getAddress">导入微信地址</view>
</view>
</template>
<script type="text/babel">
// import { CitySelect } from "vue-ydui/dist/lib.rem/cityselect";
// import District from "@/utils/area";
import simpleAddress from "@/components/simple-address/simple-address.nvue";
import { getAddress, postAddress, district } from "@/api/user";
import CitySelect from "@/components/CitySelect";
import { getAddress, postAddress, getCity } from "@/api/user";
import attrs, { required, chs_phone } from "@/utils/validate";
import { validatorDefaultCatch } from "@/utils/dialog";
// import { openAddress } from "@/libs/wechat";
import { isWeixin } from "@/utils";
export default {
name: "AddAddress",
components: {
// CitySelect
simpleAddress
CitySelect
},
data() {
return {
show2: false,
model2: "",
districts: [],
district: [],
id: 0,
userAddress: { isDefault: 0 },
address: {},
isWechat: isWeixin(),
selectAddressValue: null,
cityPickerValueDefault: [0, 0, 1],
pickerText: ""
addressText: ""
};
},
mounted: function() {
let id = this.$yroute.query.id;
this.id = id;
// document.title = !id ? "添加地址" : "修改地址";
this.getUserAddress();
district().then(res => {
// city_list 市
// county_list 区
// province_list 省
this.districts = res.data;
});
this.getCityList();
},
watch: {
addressText(nextModel2) {
console.log(nextModel2, 8585858585);
}
},
methods: {
openAddres() {
// 根据 label 获取
if (this.address.province) {
// 这个插件有个问题,直辖市的 city 必须得是 市辖区
try {
let str = "市";
let city = this.address.city;
if (this.address.province.indexOf(str) != -1) {
city = "市辖区";
}
var index = this.$refs.simpleAddress.queryIndex(
[this.address.province, city, this.address.district],
"label"
);
this.cityPickerValueDefault = index.index;
} catch (error) {}
}
this.$refs.simpleAddress.open();
// var index = this.$refs.simpleAddress.queryIndex(
// [13, 1302, 130203],
// "value"
// );
// this.cityPickerValueDefault = index.index;
// this.$refs.simpleAddress.open();
},
onConfirm(e) {
this.pickerText = JSON.stringify(e);
this.model2 = e.label;
this.address.province = e.labelArr[0] || "";
this.address.city = e.labelArr[1] || "";
this.address.district = e.labelArr[2] || "";
getCityList: function() {
let that = this;
getCity()
.then(res => {
that.district = res.data;
that.ready = true;
})
.catch(err => {
that.$dialog.error(err.msg);
});
},
getUserAddress: function() {
if (!this.id) return false;
let that = this;
getAddress(that.id).then(res => {
that.userAddress = res.data;
that.model2 =
that.addressText =
res.data.province + " " + res.data.city + " " + res.data.district;
that.address.province = res.data.province;
that.address.city = res.data.city;
@ -151,9 +106,12 @@ export default {
},
getAddress() {},
async submit() {
console.log(this);
console.log(this.address);
console.log(this.addressText);
let name = this.userAddress.realName,
phone = this.userAddress.phone,
model2 = this.model2,
addressText = this.addressText,
detail = this.userAddress.detail,
isDefault = this.userAddress.isDefault;
try {
@ -166,9 +124,9 @@ export default {
required(required.message("联系电话")),
chs_phone(chs_phone.message())
],
model2: [required("请选择地址")],
addressText: [required("请选择地址")],
detail: [required(required.message("具体地址"))]
}).validate({ name, phone, model2, detail });
}).validate({ name, phone, addressText, detail });
} catch (e) {
return validatorDefaultCatch(e);
}
@ -204,7 +162,7 @@ export default {
});
} catch (err) {
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
@ -213,17 +171,17 @@ export default {
ChangeIsDefault: function() {
this.userAddress.isDefault = !this.userAddress.isDefault;
},
closeaArea() {
this.show2 = false;
},
result2(ret) {
let values = ret.mp.detail.values;
this.closeaArea();
this.address.province = values[0].name || "";
this.address.city = values[1].name || "";
this.address.district = values[2].name || "";
this.model2 =
this.address.province + this.address.city + this.address.district;
result(values) {
console.log(this);
console.log(values);
this.address = {
province: values.province.name || "",
city: values.city.name || "",
district: values.district.name || ""
};
this.addressText = `${this.address.province}${this.address.city}${this.address.district}`;
// this.addressText =
// this.address.province + this.address.city + this.address.district;
}
}
};