selfconfig.vue 10 KB

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