selfconfig.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. console.log(this.userInfo)
  119. let data = {
  120. ...this.userInfo,
  121. avatar: this.userInfo.avatar[0]
  122. }
  123. // console.log(data,'upifp')
  124. this.$u.api.editCustomerInfo(data).then(res => {
  125. this.modal_show = false
  126. if (this.personnelReview === 5) {
  127. uni.showToast({
  128. title: '修改成功,请等待审核'
  129. });
  130. } else {
  131. uni.showToast({
  132. title: '修改成功'
  133. });
  134. }
  135. setTimeout(async () => {
  136. await this.goPage('/pages/user/user', 'switchTab');
  137. await this.getCustomerInfo();
  138. }, 100);
  139. }).catch(err => {
  140. this.modal_show = false
  141. });
  142. },
  143. // 重新设置
  144. replaceConfig() {
  145. if (!this.userInfo.name) {
  146. this.$api.msg('请填写个人名称');
  147. return;
  148. } else if (!this.userInfo.contact.mobile) {
  149. this.$api.msg('请填写联系人电话');
  150. return;
  151. } else if (!this.userInfo.contact.districtCode) {
  152. this.$api.msg('请选择地址');
  153. return;
  154. } else if (!this.userInfo.contact.address) {
  155. this.$api.msg('请填写详细地址');
  156. return;
  157. }
  158. this.modal_show = true
  159. },
  160. // 获取省市区
  161. pickerRegionChange(row) {
  162. console.log(row,'row+++++++++')
  163. this.userInfo.provinceCode = row[0].value;
  164. this.userInfo.cityCode = row[1].value;
  165. this.userInfo.districtCode = row[2].value;
  166. this.userInfo.contact.provinceCode = row[0].value;
  167. this.userInfo.contact.cityCode = row[1].value;
  168. this.userInfo.contact.districtCode = row[2].value;
  169. this.region_name = row[0].label + '-' + row[1].label + '-' + row[2].label;
  170. },
  171. addressBlur() {
  172. if (!this.region_name) {
  173. this.$api.msg('请选择所属区域');
  174. return;
  175. }
  176. },
  177. // 上传图片
  178. uploadSuccess(res) {
  179. const uploadPicUrl = `${webUrl.QINIU_URL}/${res.key}`;
  180. // console.log(res.key, uploadPicUrl);
  181. // console.log(uploadPicUrl,'uploadPicUrl++++++++++',this.userInfo.avatar)
  182. this.userInfo.avatar = [uploadPicUrl];
  183. // this.upimage = uploadPicUrl
  184. },
  185. // 获取用户信息
  186. async getCustomerInfo() {
  187. this.$u.api.getCustomerInfo().then(data => {
  188. uni.stopPullDownRefresh();
  189. let contact = {};
  190. if (data.data.contact.length) {
  191. contact = {
  192. id: data.data.contact[0].id,
  193. provinceCode: data.data.contact[0].provinceCode,
  194. cityCode: data.data.contact[0].cityCode,
  195. districtCode: data.data.contact[0].districtCode,
  196. address: data.data.contact[0].address,
  197. mobile: data.data.contact[0].mobile || data.data.mobile
  198. };
  199. } else {
  200. contact = {
  201. provinceCode: '',
  202. cityCode: '',
  203. districtCode: '',
  204. address: '',
  205. mobile: data.data.mobile
  206. };
  207. }
  208. this.userInfo = {
  209. ...data.data,
  210. avatar: [data.data.avatar],
  211. contact: contact
  212. };
  213. console.log(data.data.contact,'this.userInfo++++++++++++');
  214. if (data.data.contact.length) {
  215. this.region_name = data.data.contact[0].area.provinceName + '-' + data.data.contact[0]
  216. .area.cityName + '-' + data.data.contact[0].area.districtName;
  217. } else {
  218. this.region_name = '';
  219. }
  220. });
  221. }
  222. }
  223. };
  224. </script>
  225. <style lang="scss">
  226. page {
  227. background: #f5f9fc;
  228. }
  229. .btn {
  230. padding: 52upx;
  231. display: flex;
  232. justify-content: space-between;
  233. .replaLogin {
  234. line-height: 80upx;
  235. box-shadow: 0px 2px 14px 0px rgba(0, 0, 0, 0.1);
  236. border-radius: 10upx;
  237. margin-right: 35upx;
  238. font-size: 30upx;
  239. text-align: center;
  240. color: #666;
  241. height: 75upx;
  242. background: rgba(241, 241, 241, 1);
  243. width: 300upx;
  244. display: inline-block;
  245. }
  246. .replaConfig {
  247. font-size: 30upx;
  248. text-align: center;
  249. color: #fff;
  250. width: 300upx;
  251. height: 75upx;
  252. border-radius: 10upx;
  253. line-height: 75upx;
  254. }
  255. }
  256. .box {
  257. background: #fff;
  258. height: 100upx;
  259. border-bottom: 1upx solid #f5f5f5;
  260. line-height: 100upx;
  261. padding: 0 20upx;
  262. font-size: 28upx;
  263. }
  264. .box .float_right {
  265. height: 100%;
  266. line-height: 100%;
  267. }
  268. .box .float_right .ibonfont {
  269. display: inline-block;
  270. vertical-align: middle;
  271. color: #999;
  272. font-size: 36upx;
  273. }
  274. .region {
  275. text-align: right;
  276. padding-top: 36upx;
  277. }
  278. .inputSty {
  279. display: inline-block;
  280. text-align: right;
  281. line-height: 100upx;
  282. height: 100upx;
  283. font-size: 28upx;
  284. vertical-align: middle;
  285. width: 340upx;
  286. }
  287. .auator {
  288. color: #333;
  289. }
  290. .auator-val {
  291. color: #666;
  292. }
  293. .auator-val .imgs {
  294. height: 80upx;
  295. width: 80upx;
  296. border-radius: 50%;
  297. vertical-align: middle;
  298. }
  299. .confirm-btn {
  300. margin-top: 50upx;
  301. height: 80upx;
  302. line-height: 80upx;
  303. font-size: $font-base + 2upx;
  304. background: $base-btn-bg;
  305. box-shadow: 0px 2px 14px 0px rgba(116, 190, 66, 0.4);
  306. border-radius: 60upx;
  307. display: inline-block;
  308. }
  309. .resetBtn {
  310. margin-top: 100upx;
  311. line-height: 80upx;
  312. border-radius: 60upx;
  313. display: inline-block;
  314. margin-left: 35upx;
  315. font-size: 30upx;
  316. text-align: center;
  317. color: #ffffff;
  318. background: $base-btn-bg;
  319. box-shadow: 0px 2px 14px 0px rgba(116, 190, 66, 0.4);
  320. width: 600upx;
  321. }
  322. </style>