complete-info.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="complete">
  3. <view v-if="showEdit == 0">
  4. <view class="com_item">
  5. <text class="label">国家/地区</text>
  6. <view class="phone_area">({{areaCode}}){{areaName}}</view>
  7. </view>
  8. <view class="com_item">
  9. <text class="label">客户手机号</text>
  10. <input type="number" class="phone" placeholder-class="place" v-model="userInfo.phone" disabled />
  11. </view>
  12. <view class="com_item">
  13. <view class="label">客户姓名</view>
  14. <view class="flexB inp">
  15. <input placeholder="请输入客户姓名" placeholder-class="place" v-model="userInfo.name" />
  16. <view class="change" v-if="userInfo.name" @click="edit(1)">
  17. <text>修改</text>
  18. <text class="iconfont iconiconfontjiantou2"></text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="com_item">
  23. <view class="label">客户昵称</view>
  24. <view class="flexB inp">
  25. <input type="text" placeholder="请输入客户昵称" placeholder-class="place" v-model="userInfo.nickname" />
  26. <view class="change" v-if="userInfo.nickname" @click="edit(2)">
  27. <text>修改</text>
  28. <text class="iconfont iconiconfontjiantou2"></text>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="com_item">
  33. <view class="label">客户性别</view>
  34. <picker @change="bindPickerChange" :range="sexList" :range-key="'name'">
  35. <view class="picker flexB">
  36. <text
  37. :style="{ color: userInfo.sex ? '#333' : '#C7C7C7' }">{{ userInfo.sex ? getSex(userInfo.sex) : '请点击选择客户性别' }}</text>
  38. <text class="iconfont iconzhcc_xiangxiajiantou"></text>
  39. </view>
  40. </picker>
  41. </view>
  42. <view class="com_item">
  43. <view class="label">客户地址</view>
  44. <view class="flexB ads_box" @click="addressList()">
  45. <text style="font-size:32rpx;color:#c7c7c7;" v-if="!address && !defaultAds">添加地址信息</text>
  46. <view class="ads_info" v-else>
  47. <view class="shop_info">
  48. <text>{{ address ? address.name : defaultAds.name }}</text>
  49. <text>{{ address ? address.phone : defaultAds.phone }}</text>
  50. </view>
  51. <view class="C_B">
  52. {{ address ? address.province : defaultAds.province }}
  53. {{ address ? address.city : defaultAds.city }}
  54. {{ address ? address.area : defaultAds.area }}
  55. {{ address ? address.address : defaultAds.address }}
  56. </view>
  57. </view>
  58. <view class="change">
  59. <text class="iconfont iconiconfontjiantou2" style="color:#c7c7c7"></text>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="com_item flexT">
  64. <view class="label">备注</view>
  65. <view class="text_box">
  66. <textarea placeholder="请输入备注信息" v-model="userInfo.remark" placeholder-class="place" />
  67. </view>
  68. <!-- <input placeholder="请输入备注信息" placeholder-class="place" class="phone"
  69. v-model="userInfo.remark" /> -->
  70. </view>
  71. <view class="fixed_btn" @click="save">保存</view>
  72. </view>
  73. <view class="edit_name" v-if="showEdit == 1">
  74. <view class='flexB'>
  75. <view class="label">客户姓名</view>
  76. <view class="flexB inp"><input placeholder="请输入客户姓名" placeholder-class="place"
  77. v-model="userInfo.name" /></view>
  78. </view>
  79. <view class="sub_btn" @click="showEdit = 0">确定</view>
  80. </view>
  81. <view class="edit_name" v-if="showEdit == 2">
  82. <view class="flexB">
  83. <view class="label">客户昵称</view>
  84. <view class="flexB inp"><input placeholder="请输入客户姓名" placeholder-class="place"
  85. v-model="userInfo.nickname" /></view>
  86. </view>
  87. <view class="sub_btn" @click="showEdit = 0">确定</view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import {
  93. completeUser,
  94. getUser,
  95. getAds
  96. } from '../../apis/shop.js';
  97. import areaList from '@/common/util/phone-area.js'
  98. export default {
  99. data() {
  100. return {
  101. sexList: [{
  102. name: '男',
  103. val: 1
  104. }, {
  105. name: '女',
  106. val: 2
  107. }],
  108. index: '',
  109. userSex: '', //显示的用户性别
  110. user_id: '', //用户id
  111. userInfo: '',
  112. showEdit: 0,
  113. address: '', //地址信息
  114. defaultAds: '', //获取的默认地址
  115. areaCode: '+86',
  116. areaName: '中国大陆', // 手机号地区名称
  117. codeList: areaList, //手机号区域选择
  118. };
  119. },
  120. onLoad(ops) {
  121. this.getUser(ops.user_id);
  122. this.user_id = ops.user_id;
  123. this.store = uni.getStorageSync('store');
  124. },
  125. onShow() {
  126. this.otherFun();
  127. //如果没有从下个页面带来的地址,获取默认地址
  128. if (!this.address) {
  129. this.getAds();
  130. }
  131. },
  132. filters: {},
  133. methods: {
  134. /*添加地址*/
  135. addressList() {
  136. uni.navigateTo({
  137. url: '../ads-list/ads-list?user_id=' + this.user_id
  138. });
  139. },
  140. //从下个页面获取的数据
  141. otherFun(object) {
  142. if (!!object) {
  143. this.address = object;
  144. }
  145. },
  146. //获取默认地址
  147. getAds() {
  148. getAds({
  149. id: this.user_id
  150. }).then(res => {
  151. if (res.code == 200) {
  152. this.store = res.data.store;
  153. this.defaultAds = res.data.address;
  154. } else {
  155. uni.showModal({
  156. content: res.data,
  157. showCancel: false
  158. });
  159. }
  160. });
  161. },
  162. getSex(val) {
  163. if (!val) return false;
  164. if (val == 1) {
  165. return '男';
  166. } else {
  167. return '女';
  168. }
  169. },
  170. edit(type) {
  171. this.showEdit = type;
  172. },
  173. //保存用户信息
  174. save() {
  175. let params = this.userInfo;
  176. params.user_id = this.user_id;
  177. completeUser(params).then(res => {
  178. if (res.code == 200) {
  179. uni.showModal({
  180. content: '保存成功',
  181. showCancel: false,
  182. success: res => {
  183. if (res.confirm) {
  184. uni.reLaunch({
  185. url: '../user-manage/user-manage'
  186. });
  187. }
  188. }
  189. });
  190. } else {
  191. uni.showModal({
  192. content: res.data || '保存失败',
  193. showCancel: false
  194. });
  195. }
  196. });
  197. },
  198. //获取用户信息
  199. getUser(user_id) {
  200. getUser({
  201. user_id
  202. }).then(res => {
  203. if (res.code == 200) {
  204. const {
  205. name,
  206. nickname,
  207. phone,
  208. sex,
  209. remark,
  210. area_code
  211. } = res.data;
  212. this.userInfo = {
  213. name,
  214. nickname,
  215. phone,
  216. sex: sex ? sex : '',
  217. remark: remark ? remark : '',
  218. };
  219. this.areaCode = area_code ? area_code : '+86'
  220. if (this.areaCode) {
  221. let index = this.areaCode.indexOf('+')
  222. let code = this.areaCode.substring(index + 1)
  223. this.codeList[0].list.map(i => {
  224. if (i.code === Number(code)) {
  225. this.areaName = i.name
  226. }
  227. })
  228. }
  229. } else {
  230. uni.showModal({
  231. content: res.data || '获取用户信息失败',
  232. showCancel: false
  233. });
  234. }
  235. });
  236. },
  237. //选择性别
  238. bindPickerChange(e) {
  239. let idx = e.target.value;
  240. this.userSex = this.sexList[idx].name;
  241. this.userInfo.sex = idx + 1;
  242. }
  243. }
  244. };
  245. </script>
  246. <style lang="scss" scoped>
  247. .co_address {
  248. padding: 30rpx;
  249. width: 100%;
  250. box-sizing: border-box;
  251. background-color: #f9f9fb;
  252. border-radius: 24rpx;
  253. margin-bottom: 30rpx;
  254. .icondizhi1 {
  255. color: $base-color;
  256. font-size: 50rpx;
  257. vertical-align: middle;
  258. }
  259. .gray {
  260. margin-left: 20rpx;
  261. }
  262. .iconiconfontjiantou2 {
  263. color: #999;
  264. }
  265. .ads_info {
  266. margin: 0 15rpx;
  267. .shop_info {
  268. font-size: 32rpx;
  269. font-weight: bold;
  270. text:last-child {
  271. font-size: 28rpx;
  272. color: #999;
  273. }
  274. }
  275. }
  276. }
  277. .complete {
  278. width: 100%;
  279. min-height: 100%;
  280. background: #fff;
  281. padding: 30rpx;
  282. box-sizing: border-box;
  283. padding-bottom: 150rpx;
  284. .com_item {
  285. width: 100%;
  286. display: flex;
  287. justify-content: space-between;
  288. margin-top: 30rpx;
  289. .phone_area {
  290. background: #f9f9fb;
  291. height: 92rpx;
  292. line-height: 92rpx;
  293. width: 75%;
  294. }
  295. .text_box {
  296. padding: 20rpx 30rpx;
  297. box-sizing: border-box;
  298. background: #f9f9fb;
  299. width: 75%;
  300. border-radius: 8rpx;
  301. font-size: 30rpx;
  302. }
  303. .label {
  304. font-size: 32rpx;
  305. font-weight: bold;
  306. margin: 20rpx 0;
  307. }
  308. input,
  309. .inp,
  310. .picker {
  311. background: #f9f9fb;
  312. height: 92rpx;
  313. line-height: 92rpx;
  314. box-sizing: border-box;
  315. }
  316. .inp,
  317. .phone {
  318. width: 75%;
  319. padding: 0 30rpx;
  320. box-sizing: border-box;
  321. }
  322. .ads_box {
  323. width: 75%;
  324. box-sizing: border-box;
  325. background: #f9f9fb;
  326. padding: 24rpx 30rpx;
  327. text,
  328. view {
  329. font-size: 30rpx;
  330. }
  331. .shop_info {
  332. margin-bottom: 10rpx;
  333. }
  334. }
  335. picker {
  336. width: 75%;
  337. }
  338. .picker {
  339. font-size: 32rpx;
  340. padding: 0 30rpx;
  341. box-sizing: border-box;
  342. .iconfont {
  343. font-size: 40rpx;
  344. color: #c7c7c7;
  345. }
  346. }
  347. .phone {
  348. background: #f9f9fb;
  349. border-radius: 8rpx;
  350. }
  351. .place {
  352. color: #c7c7c7;
  353. font-size: 30rpx;
  354. }
  355. .inp {
  356. .change {
  357. text {
  358. font-size: 30rpx;
  359. color: #c7c7c7;
  360. }
  361. }
  362. input {
  363. width: 70%;
  364. color: #333;
  365. height: 100%;
  366. font-size: 30rpx;
  367. }
  368. }
  369. }
  370. .edit_name {
  371. margin-top: 30rpx;
  372. .label {
  373. font-size: 32rpx;
  374. font-weight: bold;
  375. }
  376. .inp {
  377. width: 75%;
  378. padding: 0 15px;
  379. box-sizing: border-box;
  380. background: #f9f9fb;
  381. border-radius: 4px;
  382. height: 98rpx;
  383. line-height: 98rpx;
  384. }
  385. .sub_btn {
  386. margin-top: 60rpx;
  387. }
  388. }
  389. }
  390. </style>