complete-info.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. },
  124. onShow() {
  125. this.otherFun();
  126. //如果没有从下个页面带来的地址,获取默认地址
  127. if (!this.address) {
  128. this.getAds();
  129. }
  130. },
  131. filters: {},
  132. methods: {
  133. /*添加地址*/
  134. addressList() {
  135. uni.navigateTo({
  136. url: '../../pagesA/pages/ads-list/ads-list?user_id=' + this.user_id
  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. .complete {
  248. width: 100%;
  249. min-height: 100%;
  250. background: #fff;
  251. padding: 30rpx;
  252. box-sizing: border-box;
  253. padding-bottom: 150rpx;
  254. .com_item {
  255. width: 100%;
  256. display: flex;
  257. justify-content: space-between;
  258. margin-top: 30rpx;
  259. .phone_area {
  260. background: #f9f9fb;
  261. height: 92rpx;
  262. line-height: 92rpx;
  263. width: 75%;
  264. }
  265. .text_box {
  266. padding: 20rpx 30rpx;
  267. box-sizing: border-box;
  268. background: #f9f9fb;
  269. width: 75%;
  270. border-radius: 8rpx;
  271. font-size: 30rpx;
  272. }
  273. .label {
  274. font-size: 32rpx;
  275. font-weight: bold;
  276. margin: 20rpx 0;
  277. }
  278. input,
  279. .inp,
  280. .picker {
  281. background: #f9f9fb;
  282. height: 92rpx;
  283. line-height: 92rpx;
  284. box-sizing: border-box;
  285. }
  286. .inp,
  287. .phone {
  288. width: 75%;
  289. padding: 0 30rpx;
  290. box-sizing: border-box;
  291. }
  292. .ads_box {
  293. width: 75%;
  294. box-sizing: border-box;
  295. background: #f9f9fb;
  296. padding: 24rpx 30rpx;
  297. text,
  298. view {
  299. font-size: 30rpx;
  300. }
  301. .shop_info {
  302. margin-bottom: 10rpx;
  303. }
  304. }
  305. picker {
  306. width: 75%;
  307. }
  308. .picker {
  309. font-size: 32rpx;
  310. padding: 0 30rpx;
  311. box-sizing: border-box;
  312. .iconfont {
  313. font-size: 40rpx;
  314. color: #c7c7c7;
  315. }
  316. }
  317. .phone {
  318. background: #f9f9fb;
  319. border-radius: 8rpx;
  320. }
  321. .place {
  322. color: #c7c7c7;
  323. font-size: 30rpx;
  324. }
  325. .inp {
  326. .change {
  327. text {
  328. font-size: 30rpx;
  329. color: #c7c7c7;
  330. }
  331. }
  332. input {
  333. width: 70%;
  334. color: #333;
  335. height: 100%;
  336. font-size: 30rpx;
  337. }
  338. }
  339. }
  340. .edit_name {
  341. margin-top: 30rpx;
  342. .label {
  343. font-size: 32rpx;
  344. font-weight: bold;
  345. }
  346. .inp {
  347. width: 75%;
  348. padding: 0 15px;
  349. box-sizing: border-box;
  350. background: #f9f9fb;
  351. border-radius: 4px;
  352. height: 98rpx;
  353. line-height: 98rpx;
  354. }
  355. .sub_btn {
  356. margin-top: 60rpx;
  357. }
  358. }
  359. }
  360. </style>