loginFirst.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <view class="name">给自己取个名字吧:</view>
  5. <view class="item">
  6. <input type="text" class="input" v-model="nickname" maxlength="10" placeholder="请输入2~10位昵称" />
  7. </view>
  8. <view class="name">请问你的性别是:</view>
  9. <view class="itemSex">
  10. <view class="sex2" :class="sex == 1?'active':''" style="margin-right: 10rpx;" @click="chkSex(1)">
  11. <image class="photo" src="../../static/me/sex_1.png" mode="widthFix" />
  12. <text>男性</text>
  13. </view>
  14. <view class="sex2" :class="sex == 2?'active':''" style="margin-left: 10rpx;" @click="chkSex(2)">
  15. <image class="photo" src="../../static/me/sex_2.png" mode="widthFix" />
  16. <text>女性</text>
  17. </view>
  18. </view>
  19. <view class="name">选一张图片作为您的头像:</view>
  20. <view class="bcenter">
  21. <block v-if="sex != 2">
  22. <view class="avator" :class="avator_str == 'a1.jpg'?'active':''" @click="selAvator('a1.jpg')">
  23. <image src="http://e.yujianmate.com/images/avator/a1.jpg" mode="widthFix" />
  24. </view>
  25. <view class="avator" :class="avator_str == 'a2.jpg'?'active':''" @click="selAvator('a2.jpg')">
  26. <image src="http://e.yujianmate.com/images/avator/a2.jpg" mode="widthFix" />
  27. </view>
  28. <view class="avator" :class="avator_str == 'a3.jpg'?'active':''" @click="selAvator('a3.jpg')">
  29. <image src="http://e.yujianmate.com/images/avator/a3.jpg" mode="widthFix" />
  30. </view>
  31. </block>
  32. <block v-if="sex != 1">
  33. <view class="avator" :class="avator_str == 'b1.jpg'?'active':''" @click="selAvator('b1.jpg')">
  34. <image src="http://e.yujianmate.com/images/avator/b1.jpg" mode="widthFix" />
  35. </view>
  36. <view class="avator" :class="avator_str == 'b2.jpg'?'active':''" @click="selAvator('b2.jpg')">
  37. <image src="http://e.yujianmate.com/images/avator/b2.jpg" mode="widthFix" />
  38. </view>
  39. <view class="avator" :class="avator_str == 'b3.jpg'?'active':''" @click="selAvator('b3.jpg')">
  40. <image src="http://e.yujianmate.com/images/avator/b3.jpg" mode="widthFix" />
  41. </view>
  42. </block>
  43. </view>
  44. <view class="blankHeight"></view>
  45. </view>
  46. <view class="btn_submit" @click="onFinish">保存</view>
  47. <ToastW3 ref="ToastW3"></ToastW3>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. components: {},
  53. data() {
  54. return {
  55. title: '',
  56. step: 1,
  57. sel: 1,
  58. sex: 1,
  59. avator_str: '',
  60. sel_tags: [],
  61. nickname: '',
  62. myinfo: {},
  63. }
  64. },
  65. onLoad() {
  66. this.loadInfo();
  67. },
  68. onShow() {},
  69. methods: {
  70. onBack() {},
  71. chkSel() {
  72. if (this.sel == 1) {
  73. this.sel = 0;
  74. } else {
  75. this.sel = 1;
  76. }
  77. },
  78. chkSex(sex) {
  79. this.sex = sex;
  80. },
  81. selAvator(act) {
  82. this.avator_str = act;
  83. },
  84. bindChange: function(e) {
  85. const val = e.detail.value
  86. // this.XLvalue = this.xueli_list[val[0]]
  87. },
  88. loadInfo() {
  89. console.log({
  90. uuid: getApp().globalData.uuid,
  91. skey: getApp().globalData.skey
  92. });
  93. uni.request({
  94. url: this.$apiHost + '/Web/getinfo',
  95. data: {
  96. uuid: getApp().globalData.uuid,
  97. skey: getApp().globalData.skey
  98. },
  99. header: {
  100. "content-type": "application/json", //自定义请求头信息
  101. },
  102. success: (res) => {
  103. console.log("----:", res.data);
  104. this.myinfo = res.data;
  105. this.nickname = res.data.nickname;
  106. this.sex = res.data.sex_id;
  107. },
  108. complete: (com) => {
  109. // uni.hideLoading();
  110. },
  111. fail: (e) => {
  112. console.log("----e:", e);
  113. }
  114. });
  115. },
  116. onFinish() {
  117. let that = this;
  118. if (this.nickname.length < 2) {
  119. that.$refs['ToastW3'].showToast({
  120. title: "请给自己取个昵称",
  121. animation: 0
  122. });
  123. return;
  124. }
  125. uni.showLoading({
  126. mask: true,
  127. });
  128. uni.request({
  129. url: this.$apiHost + '/Web/editInfo', //仅为示例,并非真实接口地址。
  130. data: {
  131. uuid: getApp().globalData.uuid,
  132. nickname: this.nickname,
  133. sex: this.sex,
  134. avator_str: this.avator_str
  135. },
  136. header: {
  137. "content-type": "application/json", //自定义请求头信息
  138. },
  139. success: (res) => {
  140. console.log("----", res.data);
  141. if (res.data.success == "yes") {
  142. if (this.myinfo.nickname == "") {
  143. uni.switchTab({
  144. url: "/pages/index/index",
  145. });
  146. } else {
  147. uni.switchTab({
  148. url: "/pages/my/my",
  149. });
  150. }
  151. } else if (res.data.success == "no") {
  152. uni.showToast({
  153. title: res.data.str,
  154. icon: "none",
  155. });
  156. } else {
  157. uni.showToast({
  158. title: "操作失败,请联系客服",
  159. icon: "none",
  160. });
  161. }
  162. },
  163. complete: (com) => {
  164. uni.hideLoading();
  165. },
  166. });
  167. },
  168. }
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. @import 'loginFirst.scss';
  173. </style>