selfconfig.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view :class="['qn-page-' + theme]">
  3. <u-alert-tips type="warning" v-if="personnelReview === 5" show-icon title="您的用户信息修改后,账户需要重新审核,请谨慎操作"
  4. :description="description"></u-alert-tips>
  5. <view class="box clearfix" style="margin-top: 20rpx;height: 180upx;">
  6. <text class="auator float_left">头像</text>
  7. <view class="float_right auator-val">
  8. <QiniuUpload @uploadSuccess="uploadSuccess" :images="userInfo.avatar" :flag="true">
  9. <!-- <div slot="cont">
  10. <view class="user-img-view">
  11. <img class="imgs" :src="userInfo.avatar" alt="" />
  12. <text class="ibonfont ibonjinru"></text>
  13. </view>
  14. </div> -->
  15. </QiniuUpload>
  16. </view>
  17. </view>
  18. <view class="box clearfix">
  19. <span class="auator float_left">用户名</span>
  20. <view class="float_right">
  21. <input type="text" class="inputSty" v-model="userInfo.name" />
  22. <text class="ibonfont ibonjinru"></text>
  23. </view>
  24. </view>
  25. <view class="box clearfix">
  26. <text class="auator float_left">联系电话</text>
  27. <view class="float_right">
  28. <input type="text" class="inputSty" v-model="userInfo.contact.mobile" />
  29. <text class="ibonfont ibonjinru"></text>
  30. </view>
  31. </view>
  32. <RegionSel @pickerRegionChange="pickerRegionChange">
  33. <view class="box clearfix">
  34. <span class="auator float_left">地址</span>
  35. <view class="region float_right">
  36. <text v-if="region_name" style="font-size: 28rpx;">{{ region_name }}</text>
  37. <text v-else style="color: #999;font-size: 28rpx;">请选择</text>
  38. <text class="ibonfont ibonjinru"></text>
  39. </view>
  40. </view>
  41. </RegionSel>
  42. <view class="box clearfix">
  43. <text class="auator float_left">详细地址</text>
  44. <view class="float_right"><input class="inputSty" @blur="addressBlur" v-model="userInfo.contact.address"
  45. placeholder="请输入" /></view>
  46. </view>
  47. <view class="btn">
  48. <span class="replaLogin" @click="logOut">退出登录</span>
  49. <view class="replaConfig primary-bg" @click="replaceConfig">保存修改</view>
  50. </view>
  51. <u-modal :show-cancel-button="true" :confirm-color="primaryColor" v-model="modal_show" :content="content"
  52. @confirm="confirmEdit"></u-modal>
  53. </view>
  54. </template>
  55. <script>
  56. import RegionSel from '../components/region/RegionSel.vue';
  57. import QiniuUpload from '../components/qiniu/QiniuUpload.vue';
  58. import webUrl from '@/config.js';
  59. export default {
  60. data() {
  61. return {
  62. region_name: '',
  63. content: '请确认是否要提交修改您的用户信息',
  64. modal_show: false,
  65. userInfo: {
  66. name: '',
  67. avatar: '',
  68. remark: '',
  69. provinceCode: '',
  70. cityCode: '',
  71. districtCode: '',
  72. longitude: '',
  73. latitude: '',
  74. contact: {
  75. provinceCode: '',
  76. cityCode: '',
  77. districtCode: '',
  78. address: '',
  79. name: '',
  80. mobile: ''
  81. }
  82. }
  83. };
  84. },
  85. components: {
  86. RegionSel,
  87. QiniuUpload
  88. },
  89. computed: {
  90. // 客户审核
  91. personnelReview() {
  92. return this.$store.state.baseSet.personnelReview;
  93. }
  94. },
  95. onLoad() {
  96. this.getCustomerInfo();
  97. },
  98. methods: {
  99. logOut() {
  100. uni.removeStorageSync('token');
  101. uni.removeStorageSync('userStatus');
  102. uni.removeStorageSync('cartPrice');
  103. uni.removeStorageSync('cartNum');
  104. uni.removeStorageSync('loginCode');
  105. uni.removeTabBarBadge({
  106. index: 2
  107. });
  108. this.$store.commit('commit_hasLogin', false);
  109. // #ifdef APP-PLUS||H5
  110. this.goPage('/pagesT/public/wxLogin', 'reLaunch');
  111. // #endif
  112. // #ifdef MP
  113. uni.navigateBack();
  114. // #endif
  115. },
  116. // 重新设置 提交
  117. confirmEdit() {
  118. this.$u.api.editCustomerInfo({
  119. ...this.userInfo,
  120. avatar: this.userInfo.avatar[0]
  121. }).then(res => {
  122. this.modal_show = false
  123. if (this.personnelReview === 5) {
  124. uni.showToast({
  125. title: '修改成功,请等待审核'
  126. });
  127. } else {
  128. uni.showToast({
  129. title: '修改成功'
  130. });
  131. }
  132. setTimeout(async () => {
  133. await this.goPage('/pages/user/user', 'switchTab');
  134. await this.getCustomerInfo();
  135. }, 100);
  136. }).catch(err => {
  137. this.modal_show = false
  138. });
  139. },
  140. // 重新设置
  141. replaceConfig() {
  142. if (!this.userInfo.name) {
  143. this.$api.msg('请填写个人名称');
  144. return;
  145. } else if (!this.userInfo.contact.mobile) {
  146. this.$api.msg('请填写联系人电话');
  147. return;
  148. } else if (!this.userInfo.contact.districtCode) {
  149. this.$api.msg('请选择地址');
  150. return;
  151. } else if (!this.userInfo.contact.address) {
  152. this.$api.msg('请填写详细地址');
  153. return;
  154. }
  155. this.modal_show = true
  156. },
  157. // 获取省市区
  158. pickerRegionChange(row) {
  159. this.userInfo.provinceCode = row[0].value;
  160. this.userInfo.cityCode = row[1].value;
  161. this.userInfo.districtCode = row[2].value;
  162. this.userInfo.contact.provinceCode = row[0].value;
  163. this.userInfo.contact.cityCode = row[1].value;
  164. this.userInfo.contact.districtCode = row[2].value;
  165. this.region_name = row[0].label + '-' + row[1].label + '-' + row[2].label;
  166. },
  167. addressBlur() {
  168. if (!this.region_name) {
  169. this.$api.msg('请选择所属区域');
  170. return;
  171. }
  172. },
  173. // 上传图片
  174. uploadSuccess(res) {
  175. const uploadPicUrl = `${webUrl.QINIU_URL}/${res.key}`;
  176. // console.log(res.key, uploadPicUrl);
  177. this.userInfo.avatar = [uploadPicUrl];
  178. },
  179. // 获取用户信息
  180. async getCustomerInfo() {
  181. this.$u.api.getCustomerInfo().then(data => {
  182. uni.stopPullDownRefresh();
  183. let contact = {};
  184. if (data.data.contact.length) {
  185. contact = {
  186. id: data.data.contact[0].id,
  187. provinceCode: data.data.contact[0].provinceCode,
  188. cityCode: data.data.contact[0].cityCode,
  189. districtCode: data.data.contact[0].districtCode,
  190. address: data.data.contact[0].address,
  191. mobile: data.data.contact[0].mobile || data.data.mobile
  192. };
  193. } else {
  194. contact = {
  195. provinceCode: '',
  196. cityCode: '',
  197. districtCode: '',
  198. address: '',
  199. mobile: data.data.mobile
  200. };
  201. }
  202. this.userInfo = {
  203. ...data.data,
  204. avatar: [data.data.avatar],
  205. contact: contact
  206. };
  207. console.log(this.userInfo);
  208. if (data.data.contact.length) {
  209. this.region_name = data.data.contact[0].area.provinceName + '-' + data.data.contact[0]
  210. .area.cityName + '-' + data.data.contact[0].area.districtName;
  211. } else {
  212. this.region_name = '';
  213. }
  214. });
  215. }
  216. }
  217. };
  218. </script>
  219. <style lang="scss">
  220. page {
  221. background: #f5f9fc;
  222. }
  223. .btn {
  224. padding: 52upx;
  225. display: flex;
  226. justify-content: space-between;
  227. .replaLogin {
  228. line-height: 80upx;
  229. box-shadow: 0px 2px 14px 0px rgba(0, 0, 0, 0.1);
  230. border-radius: 10upx;
  231. margin-right: 35upx;
  232. font-size: 30upx;
  233. text-align: center;
  234. color: #666;
  235. height: 75upx;
  236. background: rgba(241, 241, 241, 1);
  237. width: 300upx;
  238. display: inline-block;
  239. }
  240. .replaConfig {
  241. font-size: 30upx;
  242. text-align: center;
  243. color: #fff;
  244. width: 300upx;
  245. height: 75upx;
  246. border-radius: 10upx;
  247. line-height: 75upx;
  248. }
  249. }
  250. .box {
  251. background: #fff;
  252. height: 100upx;
  253. border-bottom: 1upx solid #f5f5f5;
  254. line-height: 100upx;
  255. padding: 0 20upx;
  256. font-size: 28upx;
  257. }
  258. .box .float_right {
  259. height: 100%;
  260. line-height: 100%;
  261. }
  262. .box .float_right .ibonfont {
  263. display: inline-block;
  264. vertical-align: middle;
  265. color: #999;
  266. font-size: 36upx;
  267. }
  268. .region {
  269. text-align: right;
  270. padding-top: 36upx;
  271. }
  272. .inputSty {
  273. display: inline-block;
  274. text-align: right;
  275. line-height: 100upx;
  276. height: 100upx;
  277. font-size: 28upx;
  278. vertical-align: middle;
  279. width: 340upx;
  280. }
  281. .auator {
  282. color: #333;
  283. }
  284. .auator-val {
  285. color: #666;
  286. }
  287. .auator-val .imgs {
  288. height: 80upx;
  289. width: 80upx;
  290. border-radius: 50%;
  291. vertical-align: middle;
  292. }
  293. .confirm-btn {
  294. margin-top: 50upx;
  295. height: 80upx;
  296. line-height: 80upx;
  297. font-size: $font-base + 2upx;
  298. background: $base-btn-bg;
  299. box-shadow: 0px 2px 14px 0px rgba(116, 190, 66, 0.4);
  300. border-radius: 60upx;
  301. display: inline-block;
  302. }
  303. .resetBtn {
  304. margin-top: 100upx;
  305. line-height: 80upx;
  306. border-radius: 60upx;
  307. display: inline-block;
  308. margin-left: 35upx;
  309. font-size: 30upx;
  310. text-align: center;
  311. color: #ffffff;
  312. background: $base-btn-bg;
  313. box-shadow: 0px 2px 14px 0px rgba(116, 190, 66, 0.4);
  314. width: 600upx;
  315. }
  316. </style>