裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

298 lines
5.5 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page flex flex-column">
  3. <image class="logo" :src="configList.logo_image" mode=""></image>
  4. <view class="title">
  5. {{ configList.logo_name }}
  6. </view>
  7. <view class="desc">
  8. 申请获取你的头像昵称
  9. </view>
  10. <view class="form">
  11. <view class="form-item">
  12. <view class="label">
  13. 头像
  14. </view>
  15. <view class="content">
  16. <button class="btn-avatar" :plain="true" :hairline="false" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  17. <image :src="userInfoForm.headImage" v-if="userInfoForm.headImage" class="avatar"
  18. mode=""></image>
  19. <image src="../static/auth/avatar.png" v-else class="avatar"
  20. mode=""></image>
  21. </button>
  22. </view>
  23. </view>
  24. <view class="form-item">
  25. <view class="label">
  26. 昵称
  27. </view>
  28. <view class="content">
  29. <input
  30. id="nickName"
  31. type="nickname"
  32. placeholder="请输入昵称"
  33. style="text-align: right;"
  34. placeholder-class="auth-placeholder"
  35. v-model="userInfoForm.nickName"
  36. />
  37. </view>
  38. </view>
  39. <view class="form-item">
  40. <view class="label">
  41. 微信号
  42. </view>
  43. <view class="content">
  44. <input
  45. id="wxCode"
  46. type="wxCode"
  47. placeholder="请输入微信号"
  48. style="text-align: right;"
  49. placeholder-class="auth-placeholder"
  50. v-model="userInfoForm.wxCode"
  51. />
  52. </view>
  53. </view>
  54. </view>
  55. <button
  56. :plain="true" :hairline="false"
  57. class="btn"
  58. open-type="getPhoneNumber"
  59. @getphonenumber="getPhone"
  60. >
  61. 获取电话号码
  62. </button>
  63. <button
  64. :plain="true" :hairline="false"
  65. class="btn btn-confirm"
  66. @click="submit"
  67. >
  68. 确认
  69. </button>
  70. </view>
  71. </template>
  72. <script>
  73. import { mapState } from 'vuex'
  74. export default {
  75. data() {
  76. return {
  77. userInfoForm: {
  78. headImage: '',
  79. nickName: '',
  80. phone : '',
  81. wxCode : '',
  82. }
  83. };
  84. },
  85. computed: {
  86. ...mapState(['userInfo']),
  87. },
  88. onShow() {},
  89. onLoad() {
  90. this.userInfoForm.phone = this.userInfo.phone || ''
  91. this.userInfoForm.nickName = this.userInfo.nickName || ''
  92. this.userInfoForm.headImage = this.userInfo.headImage || ''
  93. this.userInfoForm.wxCode = this.userInfo.wxCode || ''
  94. },
  95. computed: {},
  96. methods: {
  97. onChooseAvatar(res) {
  98. this.$Oss.ossUpload(res.target.avatarUrl)
  99. .then(url => {
  100. this.userInfoForm.headImage = url
  101. })
  102. },
  103. getPhone(e){
  104. this.$api('bindPhone', {
  105. code : e.detail.code
  106. }, res => {
  107. if(res.code == 200){
  108. let phoneObj = JSON.parse(res.result)
  109. if(phoneObj.errmsg == 'ok'){
  110. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  111. }else{
  112. uni.showModal({
  113. title: phoneObj.errmsg
  114. })
  115. }
  116. console.log(phoneObj);
  117. }
  118. })
  119. },
  120. submit() {
  121. let self = this
  122. uni.createSelectorQuery().in(this)
  123. .select("#nickName")
  124. .fields({
  125. properties: ["value"],
  126. })
  127. .exec((res) => {
  128. const nickName = res?.[0]?.value
  129. self.userInfoForm.nickName = nickName
  130. if (self.$utils.verificationAll(self.userInfoForm, {
  131. headImage: '请选择头像',
  132. nickName: '请填写昵称',
  133. phone: '请填写手机号',
  134. wxCode: '请填写微信号',
  135. })) {
  136. return
  137. }
  138. self.$api('updateInfo', {
  139. headImage : self.userInfoForm.headImage,
  140. nickName : self.userInfoForm.nickName,
  141. phone : self.userInfoForm.phone,
  142. wxCode : self.userInfoForm.wxCode,
  143. }, res => {
  144. if (res.code == 200) {
  145. uni.reLaunch({
  146. url:'/pages/index/index'
  147. })
  148. }
  149. })
  150. })
  151. },
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .page {
  157. background-color: $uni-fg-color;
  158. position: relative;
  159. width: 100vw;
  160. height: 100vh;
  161. padding-top: calc(#{$navbar-height} + var(--status-bar-height) + 20rpx);
  162. padding-left: 60rpx;
  163. padding-right: 60rpx;
  164. box-sizing: border-box;
  165. justify-content: flex-start;
  166. }
  167. .logo {
  168. width: 148rpx;
  169. height: 148rpx;
  170. margin-top: 96rpx;
  171. }
  172. .title {
  173. color: #333333;
  174. font-size: 32rpx;
  175. font-weight: 900;
  176. margin-top: 20rpx;
  177. }
  178. .desc {
  179. color: #474747;
  180. font-size: 28rpx;
  181. margin-top: 40rpx;
  182. }
  183. .form {
  184. margin-top: 120rpx;
  185. margin-bottom: 193rpx;
  186. width: 100%;
  187. display: flex;
  188. flex-direction: column;
  189. align-items: center;
  190. box-sizing: border-box;
  191. .form-item {
  192. width: 100%;
  193. min-height: 136rpx;
  194. border-bottom: 1rpx solid #E8E8E8;
  195. display: flex;
  196. align-items: center;
  197. justify-content: center;
  198. &:first-child {
  199. border-top: 1rpx solid #E8E8E8;
  200. }
  201. .label {
  202. width: 110rpx;
  203. font-size: 36rpx;
  204. font-weight: 500;
  205. text-align: left;
  206. color: #474747;
  207. }
  208. .content {
  209. flex: 1;
  210. text-align: right;
  211. }
  212. }
  213. .btn-avatar {
  214. background: transparent;
  215. border: none;
  216. border-radius: none;
  217. box-shadow: none;
  218. padding: 0;
  219. margin: 0;
  220. font-size: 0;
  221. text-align: right;
  222. }
  223. .avatar {
  224. display: inline-block;
  225. width: 96rpx;
  226. height: 96rpx;
  227. }
  228. .btn-phone {
  229. border: none;
  230. border-radius: 0;
  231. padding: 7rpx;
  232. margin: 0;
  233. text-align: right;
  234. color: #7C7C7C;
  235. font-size: 26rpx;
  236. line-height: 1;
  237. }
  238. }
  239. .auth-placeholder {
  240. color: #7C7C7C;
  241. font-size: 26rpx;
  242. }
  243. .btn {
  244. width: 100%;
  245. height: auto;
  246. border-radius: 45rpx;
  247. color: #07C160;
  248. border-color: #07C160;
  249. padding: 25rpx 0;
  250. box-sizing: border-box;
  251. font-size: 28rpx;
  252. line-height: 1;
  253. margin: 0;
  254. &-confirm {
  255. background-color: #07C160;
  256. color: #FFFFFF;
  257. }
  258. & + & {
  259. margin-top: 34rpx;
  260. }
  261. }
  262. </style>