bind.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="container main">
  3. <view class="one">
  4. <view class="one_cont">
  5. <view class="one_1">用户信息</view>
  6. <view class="one_2">
  7. <view class="one_label">
  8. <view class="left">账号</view>
  9. <view class="right textOne">
  10. <text>{{form.account||'暂无账号'}}</text>
  11. </view>
  12. </view>
  13. <view class="one_label">
  14. <view class="left">昵称</view>
  15. <view class="right textOne">
  16. <text>{{form.nick_name||'暂无昵称'}}</text>
  17. </view>
  18. </view>
  19. <view class="one_label">
  20. <view class="left">性别</view>
  21. <view class="right textOne">
  22. <text>{{gender_name||'暂无性别'}}</text>
  23. </view>
  24. </view>
  25. <view class="one_label">
  26. <view class="left">所属产业</view>
  27. <view class="right textOne">
  28. <text>{{form.industry||'暂无所属产业'}}</text>
  29. </view>
  30. </view>
  31. <view class="one_label">
  32. <view class="left">手机号</view>
  33. <view class="right textOne">
  34. <text>{{form.phone||'暂无手机号'}}</text>
  35. </view>
  36. </view>
  37. <view class="one_label">
  38. <view class="left">电子邮箱</view>
  39. <view class="right textOne">
  40. <text>{{form.email||'暂无电子邮箱'}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="button">
  46. <button class="warning" size="mini" type="warn" @tap.stop="toBind()">账号绑定</button>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. components: {},
  54. data() {
  55. return {
  56. openid: '',
  57. user: {},
  58. form: {},
  59. gender_name: '',
  60. // 字典表
  61. genderList: [],
  62. }
  63. },
  64. onLoad: async function(e) {
  65. const that = this;
  66. await that.searchOpenids();
  67. await that.searchToken();
  68. await that.searchOther();
  69. await that.search();
  70. },
  71. methods: {
  72. async searchOpenids() {
  73. const that = this;
  74. uni.getStorage({
  75. key: 'openid',
  76. success: function(res) {
  77. that.$set(that, `openid`, res.data);
  78. },
  79. fail: function(err) {
  80. uni.login({
  81. success: async function(res) {
  82. if (res.code) {
  83. const aee = await that.$app('/wechat/api/login/app',
  84. 'GET', {
  85. js_code: res.code,
  86. config: that.$config.wx_projectkey
  87. })
  88. if (aee.errcode == '0') {
  89. uni.setStorage({
  90. key: "openid",
  91. data: aee.data.openid
  92. })
  93. that.$set(that, `openid`, aee.data.openid);
  94. } else {
  95. uni.showToast({
  96. title: aee.errmsg,
  97. icon: 'none'
  98. })
  99. }
  100. } else {
  101. uni.showToast({
  102. title: res.errMsg,
  103. icon: 'none'
  104. })
  105. }
  106. }
  107. });
  108. }
  109. })
  110. },
  111. // 用户信息
  112. searchToken() {
  113. const that = this;
  114. try {
  115. const res = uni.getStorageSync('token');
  116. if (res) {
  117. const user = that.$jwt(res);
  118. that.$set(that, `user`, user);
  119. }
  120. } catch (e) {}
  121. },
  122. async searchOther() {
  123. const that = this;
  124. let res;
  125. // 查询性别
  126. res = await that.$api(`/dictData`, 'GET', {
  127. code: 'gender',
  128. is_use: '0',
  129. })
  130. if (res.errcode == '0') that.$set(that, `genderList`, res.data);
  131. },
  132. // 查询
  133. async search() {
  134. const that = this;
  135. if (that.user && that.user.id) {
  136. let res;
  137. res = await that.$api(`/user/${that.user.id}`, 'GET', {})
  138. if (res.errcode == '0') {
  139. that.$set(that, `form`, res.data)
  140. if (res.data.gender) {
  141. let data = that.genderList.find(i => i.value == res.data.gender);
  142. if (data) that.$set(that, `gender_name`, data.label)
  143. }
  144. } else {
  145. uni.showToast({
  146. title: res.errmsg,
  147. });
  148. }
  149. }
  150. },
  151. // 账号绑定
  152. toBind() {
  153. console.log('账号绑定');
  154. },
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .main {
  160. .one {
  161. .one_cont {
  162. padding: 2vw 0 0 0;
  163. .one_1 {
  164. text-indent: 10px;
  165. border-left: 3px solid var(--f3CColor);
  166. font-weight: bold;
  167. font-size: var(--font16Size);
  168. }
  169. .one_2 {
  170. padding: 2vw;
  171. .one_label {
  172. display: flex;
  173. justify-content: space-between;
  174. padding: 4vw;
  175. border-bottom: 1px solid var(--f9Color);
  176. font-size: var(--font14Size);
  177. color: var(--f69Color);
  178. .right {
  179. text-align: right;
  180. width: 60vw;
  181. }
  182. }
  183. }
  184. }
  185. .button {
  186. margin: 2vw 0 0 0;
  187. text-align: center;
  188. .warning {
  189. background: var(--f3CColor);
  190. }
  191. .danger {
  192. background: var(--fF0Color);
  193. }
  194. button {
  195. margin: 0 1vw 0 0;
  196. }
  197. }
  198. }
  199. }
  200. </style>