userdata.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="content">
  3. <view class="tit">
  4. 上传收款码
  5. </view>
  6. <view class="up-wrap" @click="imgsub('upimg')">
  7. <image :src="upimg" mode="" v-if="upimg"></image>
  8. <image v-else src="../../static/img/upimg.png" mode=""></image>
  9. </view>
  10. <view class="tit">
  11. 基本信息
  12. </view>
  13. <view class="base-info">
  14. <view class="base-item">
  15. <view class="item-name">头像</view>
  16. <view class="avatar" @click="imgsub('avatar')">
  17. <image :src="avatar || '../../static/error/missing-face.png'" mode="" ></image>
  18. </view>
  19. </view>
  20. <view class="base-item flex">
  21. <view class="item-name">昵称</view>
  22. <input type="text" value="" class="item-val" placeholder="输入您的昵称" v-model="nickname" />
  23. </view>
  24. <view class="base-item flex">
  25. <view class="item-name">ID</view>
  26. <input type="text" value="" class="item-val" placeholder="输入您的昵称" v-model="uid" disabled/>
  27. </view>
  28. <view class="base-item flex">
  29. <view class="item-name">会员等级</view>
  30. <input type="text" class="item-val" placeholder="" v-model="vip_name" disabled/>
  31. </view>
  32. <view class="base-item flex">
  33. <view class="item-name">手机号</view>
  34. <input type="text" value="" class="item-val" placeholder="输入您的手机号" v-model="phone" />
  35. </view>
  36. <view class="base-item flex">
  37. <view class="item-name">姓名</view>
  38. <input type="text" value="" class="item-val" placeholder="输入您的姓名" v-model="real_name" />
  39. </view>
  40. <view class="base-item flex">
  41. <view class="item-name">微信号</view>
  42. <input type="text" value="" class="item-val" placeholder="输入您的微信号" v-model="wx_no" />
  43. </view>
  44. <view class="base-item flex">
  45. <view class="item-name">支付宝姓名</view>
  46. <input type="text" value="" class="item-val" placeholder="输入您的支付宝姓名" v-model="alipay_name" />
  47. </view>
  48. <view class="base-item flex">
  49. <view class="item-name">支付宝账号</view>
  50. <input type="text" value="" class="item-val" placeholder="输入您的支付宝账号" v-model="alipay_no" />
  51. </view>
  52. <view class="base-item flex">
  53. <view class="item-name">开户行</view>
  54. <input type="text" value="" class="item-val" placeholder="输入您的开户行" v-model="account_Bank" />
  55. </view>
  56. <view class="base-item flex">
  57. <view class="item-name">所属支行</view>
  58. <input type="text" value="" class="item-val" placeholder="输入所属支行" v-model="bank_branch" />
  59. </view>
  60. <view class="base-item flex">
  61. <view class="item-name">开户行姓名</view>
  62. <input type="text" value="" class="item-val" placeholder="输入您的开户行姓名" v-model="bank_name" />
  63. </view>
  64. <view class="base-item flex">
  65. <view class="item-name">银行卡账号</view>
  66. <input type="text" value="" class="item-val" placeholder="输入您的银行卡账号" v-model="bank_card" />
  67. </view>
  68. </view>
  69. <view class="btn" @click="subInfo">提交保存</view>
  70. <view class="btn1" @click="toLogout">退出登录</view>
  71. <view class="jg" style="height: 70rpx;">
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import { mapState, mapMutations } from 'vuex';
  77. import { getUserInfo } from '@/api/user.js';
  78. // import { upload } from '@/api/order.js';
  79. import { uploads, edit, upload} from '@/api/user.js';
  80. import { logout } from '@/api/set.js';
  81. export default {
  82. computed: {
  83. ...mapState('user',['userInfo'])
  84. },
  85. data() {
  86. return {
  87. avatar: '',
  88. upimg: '',
  89. real_name: '',
  90. nickname: '',
  91. phone: '',
  92. wx_no: '',
  93. alipay_name: '',
  94. alipay_no: '',
  95. account_Bank: '',
  96. bank_branch: '',
  97. bank_card: '',
  98. bank_name: '',
  99. // birthday: '',
  100. city: '',
  101. card_id: '',//身份证
  102. uid: '',
  103. vip_name: ''
  104. }
  105. },
  106. onLoad() {
  107. let obj = this
  108. obj.avatar = obj.userInfo.avatar || ''
  109. obj.alipay_name = obj.userInfo.alipay_name || ''
  110. obj.alipay_no = obj.userInfo.alipay_no || '',
  111. obj.bank_branch = obj.userInfo.bank_branch || ''
  112. obj.account_Bank = obj.userInfo.account_Bank || ''
  113. obj.bank_card = obj.userInfo.bank_card || ''
  114. obj.uid = obj.userInfo.uid
  115. obj.bank_name = obj.userInfo.bank_name || ''
  116. // obj.birthday = obj.userInfo.birthday || ''
  117. // obj.card_id: obj.userInfo.card_id || ''
  118. obj.upimg = obj.userInfo.wx_qr || ''
  119. obj.wx_no = obj.userInfo.wx_no || ''
  120. obj.phone = obj.userInfo.phone || ''
  121. obj.real_name = obj.userInfo.real_name || ''
  122. obj.nickname = obj.userInfo.nickname || ''
  123. console.log(obj.userInfo.vip_name,'obj.userInfo.vip_name')
  124. obj.vip_name = obj.userInfo.vip_name || '暂无'
  125. },
  126. methods: {
  127. ...mapMutations('user', ['setUserInfo', 'setOrderInfo','logout']),
  128. //退出登录
  129. toLogout() {
  130. let obj = this;
  131. uni.showModal({
  132. content: '确定要退出登录么',
  133. success: e => {
  134. if (e.confirm) {
  135. logout({}).then(e => {
  136. obj.logout();
  137. uni.navigateTo({
  138. url:'/pages/public/login'
  139. })
  140. })
  141. .catch(e => {
  142. console.log(e);
  143. });
  144. }
  145. }
  146. });
  147. },
  148. imgsub(text) {
  149. console.log('imgsub');
  150. upload({
  151. filename: ''
  152. }).then(data => {
  153. // this.upimg = data[0].url;
  154. this.$set(this,text,data[0].url)
  155. });
  156. },
  157. getUserInfo() {
  158. getUserInfo({})
  159. .then(({ data }) => {
  160. this.setUserInfo(data);
  161. })
  162. .catch(e => {
  163. console.log(e);
  164. });
  165. },
  166. bindDateChange(e) {
  167. this.birthday = e.detail.value
  168. },
  169. subInfo() {
  170. let obj = this
  171. if(obj.upimg == '') {
  172. obj.$api.msg('请上传收款码')
  173. return
  174. }
  175. if(obj.avatar == '') {
  176. obj.$api.msg('请上传头像')
  177. return
  178. }
  179. if(obj.nickname == '') {
  180. obj.$api.msg('请输入昵称')
  181. return
  182. }
  183. if(obj.phone == '') {
  184. obj.$api.msg('请输入手机号')
  185. return
  186. }
  187. const reg = /^(\+?0?86-?)?1[\d]\d{9}$/;
  188. if (!reg.test(obj.phone)) {
  189. obj.$api.msg('请填写正确的手机号码');
  190. return;
  191. }
  192. if(obj.real_name == '') {
  193. obj.$api.msg('请输入姓名')
  194. return
  195. }
  196. if(obj.wx_no == '') {
  197. obj.$api.msg('请输入微信号')
  198. return
  199. }
  200. if(obj.alipay_name == '') {
  201. obj.$api.msg('请输入支付宝姓名')
  202. return
  203. }
  204. if(obj.alipay_no == '') {
  205. obj.$api.msg('请输入支付宝账号')
  206. return
  207. }
  208. if(obj.account_Bank == '') {
  209. obj.$api.msg('请输入开户行')
  210. return
  211. }
  212. if(obj.bank_branch == '') {
  213. obj.$api.msg('请输入所属支行')
  214. return
  215. }
  216. if(obj.bank_name == '') {
  217. obj.$api.msg('请输入开户姓名')
  218. return
  219. }
  220. if(obj.bank_card == '') {
  221. obj.$api.msg('请输入银行卡账号')
  222. return
  223. }
  224. // if(obj.birthday == '') {
  225. // obj.$api.msg('请输入出生日期')
  226. // return
  227. // }
  228. uni.showLoading({
  229. title: '提交中...',
  230. mask:true
  231. })
  232. edit({
  233. avatar: obj.avatar,
  234. alipay_name: obj.alipay_name,
  235. alipay_no: obj.alipay_no,
  236. account_Bank: obj.account_Bank,
  237. bank_branch: obj.bank_branch,
  238. bank_card: obj.bank_card,
  239. bank_name: obj.bank_name,
  240. // birthday: obj.birthday,
  241. // card_id: obj.card_id,
  242. wx_no: obj.wx_no,
  243. phone: obj.phone,
  244. real_name: obj.real_name,
  245. nickname: obj.nickname,
  246. wx_qr: obj.upimg
  247. }).then( res => {
  248. obj.getUserInfo()
  249. obj.$api.msg('修改成功');
  250. setTimeout(()=> {
  251. uni.switchTab({
  252. url:'/pages/user/user'
  253. });
  254. }, 1000);
  255. }).catch( err => {
  256. console.log(err)
  257. })
  258. }
  259. }
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. .tit {
  264. padding: 30rpx 25rpx;
  265. font-size: 32rpx;
  266. font-family: PingFang SC;
  267. font-weight: bold;
  268. color: #101010;
  269. }
  270. .up-wrap {
  271. margin-left: 30rpx;
  272. width: 225rpx;
  273. height: 225rpx;
  274. background: #FFFFFF;
  275. border-radius: 10rpx;
  276. image {
  277. width: 225rpx;
  278. height: 225rpx;
  279. border-radius: 10rpx;
  280. }
  281. }
  282. .base-info {
  283. margin: auto;
  284. width: 702rpx;
  285. // height: 1106px;
  286. background: #FFFFFF;
  287. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  288. border-radius: 20rpx;
  289. .base-item {
  290. border: 1px solid #eee;
  291. line-height: 100rpx;
  292. font-size: 30rpx;
  293. font-family: PingFang SC;
  294. font-weight: 500;
  295. color: #333333;
  296. padding-left: 25rpx;
  297. .avatar {
  298. margin: auto;
  299. width: 200rpx;
  300. height: 200rpx;
  301. border-radius: 50%;
  302. // background-color: #aaa;
  303. image {
  304. width: 200rpx;
  305. height: 200rpx;
  306. border-radius: 50%;
  307. }
  308. }
  309. .item-name {
  310. font-weight: bold;
  311. }
  312. .item-val {
  313. display: block;
  314. line-height: 100rpx;
  315. height: 100rpx;
  316. width: 478rpx;
  317. font-size: 28rpx;
  318. font-family: PingFang SC;
  319. font-weight: 400;
  320. color: #000;
  321. }
  322. }
  323. }
  324. .btn {
  325. margin: 70rpx auto 0;
  326. width: 702rpx;
  327. line-height: 84rpx;
  328. background: linear-gradient(30deg, #FF4C4C, #FE6238);
  329. border-radius: 10rpx;
  330. font-size: 32rpx;
  331. font-family: PingFang SC;
  332. font-weight: bold;
  333. color: #FFFFFF;
  334. text-align: center;
  335. }
  336. .btn1 {
  337. margin: 30rpx auto 0;
  338. width: 702rpx;
  339. line-height: 84rpx;
  340. color: #FF4C4C;
  341. border: 1px solid #FF4C4C;
  342. background-color: #fff;
  343. border-radius: 10rpx;
  344. font-size: 32rpx;
  345. font-family: PingFang SC;
  346. font-weight: bold;
  347. text-align: center;
  348. }
  349. </style>