userinfo.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="content">
  3. <view class="row">
  4. <view class="left">
  5. <text class="tit" style="width: 160upx;">{{ $t('foo.zh') }}</text>
  6. <view class="tit">ID:{{ userInfo.id }}</view>
  7. </view>
  8. <input class="input" type="text" disabled="true" v-model="userInfo.username" placeholder-class="placeholder" />
  9. </view>
  10. <view class="row1">
  11. <text class="tit">{{ $t('foo.tx') }}</text>
  12. <view class="background-img" @click.stop="imgsub"><image class="background-img" :src="userInfo.avatar" mode="aspectFill"></image></view>
  13. </view>
  14. <view class="row">
  15. <text class="tit" style="width: 160upx; color: #bdbdbd;">{{ $t('foo.nc') }}*</text>
  16. <input class="input" type="text" v-model="userInfo.nickname" placeholder-class="placeholder" placeholder="请填写" />
  17. </view>
  18. <view class="row">
  19. <text class="tit" style="width: 160upx; color: #bdbdbd;">{{ $t('foo.yhzh') }}*</text>
  20. <input class="input" type="text" v-model="userInfo.bank_card_no" placeholder-class="placeholder" placeholder="请填写" />
  21. </view>
  22. <view class="row">
  23. <view class="left">
  24. <text class="tit" style="width: 160upx; color: #bdbdbd;">{{ $t('foo.scyh') }}*</text>
  25. <view class="image"><image src="../../static/img/user-bank.png" mode=""></image></view>
  26. </view>
  27. <input class="input" type="text" v-model="userInfo.bank_of_deposit" placeholder-class="placeholder" placeholder="请填写" />
  28. </view>
  29. <!-- <view class="row">
  30. <text class="tit">ID</text>
  31. <input class="input" type="text" disabled="true" v-model="userInfo.id" placeholder-class="placeholder" />
  32. </view> -->
  33. <view class="row1">
  34. <view class="left">
  35. <text class="tit">{{ $t('foo.zfbskm') }}</text>
  36. <view class="image"><image src="../../static/img/ali.png" mode=""></image></view>
  37. </view>
  38. <view class="background-img1" @click.stop="imgsubali">
  39. <image class="background-img1" :src="userInfo.ali || '../../static/img/upload.png'" mode="aspectFill"></image>
  40. </view>
  41. </view>
  42. <view class="row1">
  43. <view class="left">
  44. <text class="tit">{{ $t('foo.wxskm') }}</text>
  45. <view class="image"><image src="../../static/img/weixin.png" mode=""></image></view>
  46. </view>
  47. <view class="background-img1" @click.stop="imgsubwechat">
  48. <image class="background-img1" :src="userInfo.wechat || '../../static/img/upload.png'" mode="aspectFill"></image>
  49. </view>
  50. </view>
  51. <view class="row">
  52. <text class="tit" style="width: 140upx; color: #bdbdbd;">{{ $t('foo.jjlxrdh') }}*</text>
  53. <input class="input" type="text" v-model="userInfo.ext_mobile" placeholder-class="placeholder" placeholder="请填写" />
  54. </view>
  55. <view class="tishi">*{{ $t('foo.bt') }}</view>
  56. <view class="add-btn" @click="confirm">{{ $t('foo.tj') }}</view>
  57. <view class="out" @click="toLogout">{{ $t('foo.tcdl') }}</view>
  58. </view>
  59. </template>
  60. <script>
  61. import { mapState, mapMutations } from 'vuex';
  62. import { uploads } from '@/api/user.js';
  63. import { userEdit, logout } from '@/api/set.js';
  64. export default {
  65. data() {
  66. return {};
  67. },
  68. onLoad() {
  69. let i = this.userInfo.id + '';
  70. console.log(i.length);
  71. if (i.length < 8) {
  72. let k = '';
  73. for (let j = 0; j < 8 - i.length; j++) {
  74. k += '0';
  75. }
  76. this.userInfo.id = k + this.userInfo.id;
  77. }
  78. uni.setNavigationBarTitle({
  79. title: this.$t('foo.sz')
  80. });
  81. },
  82. computed: {
  83. ...mapState('user', ['userInfo'])
  84. },
  85. methods: {
  86. ...mapMutations('user', ['logout']),
  87. imgsub() {
  88. console.log('上传头像');
  89. uploads({
  90. filename: ''
  91. }).then(res => {
  92. // console.log("data",data);
  93. // this.userInfo.avatar = data.fullurl;
  94. console.log(res, '++++++++++++++++');
  95. this.userInfo.avatar = res[0].fullurl;
  96. });
  97. },
  98. imgsubali() {
  99. console.log('上传支付宝二维码');
  100. uploads({
  101. filename: ''
  102. }).then(res => {
  103. // console.log("data",data);
  104. // this.userInfo.avatar = data.fullurl;
  105. console.log(res, '++++++++++++++++');
  106. this.userInfo.ali = res[0].fullurl;
  107. });
  108. },
  109. imgsubwechat() {
  110. console.log('上传微信二维码');
  111. uploads({
  112. filename: ''
  113. }).then(res => {
  114. // console.log("data",data);
  115. // this.userInfo.avatar = data.fullurl;
  116. console.log(res, '++++++++++++++++');
  117. this.userInfo.wechat = res[0].fullurl;
  118. });
  119. },
  120. confirm() {
  121. let data = '';
  122. if (this.userInfo.nickname == '') {
  123. uni.showModal({
  124. title: this.$t('foo.ts'),
  125. content: this.$t('foo.jtxzsxm')
  126. });
  127. return;
  128. }
  129. if (this.userInfo.bank_card_no == '') {
  130. uni.showModal({
  131. title: this.$t('foo.ts'),
  132. content: this.$t('foo.jtxyhkh')
  133. });
  134. return;
  135. }
  136. if (this.userInfo.bank_of_deposit == '') {
  137. uni.showModal({
  138. title: this.$t('foo.ts'),
  139. content: this.$t('foo.jtxkhh')
  140. });
  141. return;
  142. }
  143. if (this.userInfo.ext_mobile == '' || this.userInfo.ext_mobile == null) {
  144. uni.showModal({
  145. title: this.$t('foo.ts'),
  146. content: this.$t('foo.jtxjjlxrdh')
  147. });
  148. return;
  149. }
  150. if (this.userInfo.avatar.length < 255) {
  151. data = {
  152. avatar: this.userInfo.avatar,
  153. nickname: this.userInfo.nickname,
  154. bank_of_deposit: this.userInfo.bank_of_deposit,
  155. bank_card_no: this.userInfo.bank_card_no,
  156. ali: this.userInfo.ali,
  157. wechat: this.userInfo.wechat,
  158. ext_mobile: this.userInfo.ext_mobile
  159. };
  160. } else {
  161. data = {
  162. avatar: '',
  163. nickname: this.userInfo.nickname,
  164. bank_of_deposit: this.userInfo.bank_of_deposit,
  165. bank_card_no: this.userInfo.bank_card_no,
  166. ali: this.userInfo.ali,
  167. wechat: this.userInfo.wechat,
  168. ext_mobile: this.userInfo.ext_mobile
  169. };
  170. }
  171. userEdit(data)
  172. .then(e => {
  173. this.$api.msg('修改成功');
  174. setTimeout(() => {
  175. uni.navigateBack({});
  176. }, 1000);
  177. console.log(e);
  178. })
  179. .catch(e => {
  180. console.log(e);
  181. });
  182. },
  183. toLogout() {
  184. let obj = this;
  185. uni.showModal({
  186. content: '确定要退出登录么',
  187. success: e => {
  188. if (e.confirm) {
  189. // logout({}).then((e) => {
  190. // uni.navigateBack();
  191. // }).catch((e) => {
  192. // console.log(e);
  193. // })
  194. logout({}).then()
  195. uni.navigateBack();
  196. obj.logout();
  197. }
  198. }
  199. });
  200. }
  201. }
  202. };
  203. </script>
  204. <style lang="scss">
  205. .row1 {
  206. display: flex;
  207. align-items: center;
  208. justify-content: space-between;
  209. position: relative;
  210. padding: 0 30upx;
  211. height: 110upx;
  212. background: #000;
  213. margin-bottom: 20upx;
  214. .toux {
  215. display: inline-block;
  216. }
  217. .tit {
  218. flex-shrink: 0;
  219. width: 120upx;
  220. font-size: $font-lg;
  221. color: #fff;
  222. }
  223. .left {
  224. display: flex;
  225. justify-content: start;
  226. }
  227. .image {
  228. width: 100rpx;
  229. height: 100rpx;
  230. image {
  231. width: 100%;
  232. height: 100%;
  233. }
  234. }
  235. .background-img {
  236. width: 100rpx;
  237. height: 100rpx;
  238. border-radius: 50%;
  239. background: #f2f2f2;
  240. }
  241. .background-img1 {
  242. width: 100rpx;
  243. height: 100rpx;
  244. background: #000000;
  245. }
  246. }
  247. .row {
  248. display: flex;
  249. align-items: center;
  250. padding: 0 30upx;
  251. height: 110upx;
  252. background: #000;
  253. .left {
  254. display: flex;
  255. justify-content: start;
  256. align-items: center;
  257. }
  258. .image {
  259. width: 100rpx;
  260. height: 100rpx;
  261. image {
  262. width: 100%;
  263. height: 100%;
  264. }
  265. }
  266. .tit {
  267. flex-shrink: 0;
  268. width: 120upx;
  269. font-size: $font-lg;
  270. color: #fff;
  271. }
  272. .input {
  273. flex: 1;
  274. text-align: right;
  275. font-size: $font-base;
  276. color: #fff;
  277. }
  278. }
  279. .tishi {
  280. padding: 20rpx 0 120rpx 24rpx;
  281. color: #fff;
  282. font-size: 26rpx;
  283. font-family: PingFang SC;
  284. font-weight: 500;
  285. color: #ffffff;
  286. }
  287. .add-btn {
  288. display: flex;
  289. align-items: center;
  290. justify-content: center;
  291. margin: 158rpx auto 30rpx;
  292. width: 560rpx;
  293. height: 80rpx;
  294. background: linear-gradient(-74deg, #ce9c6d, #ffecd6);
  295. border-radius: 40px;
  296. color: #ffffff;
  297. }
  298. .out {
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. margin: 0 auto 30rpx;
  303. width: 560rpx;
  304. height: 80rpx;
  305. border: 1px solid #ffecd6;
  306. background: #ffffff;
  307. border-radius: 40px;
  308. color: #ce9c6d;
  309. }
  310. </style>