裂变星小程序-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.

303 lines
5.6 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(['configList'])
  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.navigateBack({
  146. delta: 2,
  147. fail: () => {
  148. uni.reLaunch({
  149. url: '/pages/index/index'
  150. })
  151. }
  152. });
  153. }
  154. })
  155. })
  156. },
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .page {
  162. background-color: $uni-fg-color;
  163. position: relative;
  164. width: 100vw;
  165. height: 100vh;
  166. padding-top: calc(#{$navbar-height} + var(--status-bar-height) + 20rpx);
  167. padding-left: 60rpx;
  168. padding-right: 60rpx;
  169. box-sizing: border-box;
  170. justify-content: flex-start;
  171. }
  172. .logo {
  173. width: 148rpx;
  174. height: 148rpx;
  175. margin-top: 96rpx;
  176. }
  177. .title {
  178. color: #333333;
  179. font-size: 32rpx;
  180. font-weight: 900;
  181. margin-top: 20rpx;
  182. }
  183. .desc {
  184. color: #474747;
  185. font-size: 28rpx;
  186. margin-top: 40rpx;
  187. }
  188. .form {
  189. margin-top: 120rpx;
  190. margin-bottom: 193rpx;
  191. width: 100%;
  192. display: flex;
  193. flex-direction: column;
  194. align-items: center;
  195. box-sizing: border-box;
  196. .form-item {
  197. width: 100%;
  198. min-height: 136rpx;
  199. border-bottom: 1rpx solid #E8E8E8;
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. &:first-child {
  204. border-top: 1rpx solid #E8E8E8;
  205. }
  206. .label {
  207. width: 110rpx;
  208. font-size: 36rpx;
  209. font-weight: 500;
  210. text-align: left;
  211. color: #474747;
  212. }
  213. .content {
  214. flex: 1;
  215. text-align: right;
  216. }
  217. }
  218. .btn-avatar {
  219. background: transparent;
  220. border: none;
  221. border-radius: none;
  222. box-shadow: none;
  223. padding: 0;
  224. margin: 0;
  225. font-size: 0;
  226. text-align: right;
  227. }
  228. .avatar {
  229. display: inline-block;
  230. width: 96rpx;
  231. height: 96rpx;
  232. }
  233. .btn-phone {
  234. border: none;
  235. border-radius: 0;
  236. padding: 7rpx;
  237. margin: 0;
  238. text-align: right;
  239. color: #7C7C7C;
  240. font-size: 26rpx;
  241. line-height: 1;
  242. }
  243. }
  244. .auth-placeholder {
  245. color: #7C7C7C;
  246. font-size: 26rpx;
  247. }
  248. .btn {
  249. width: 100%;
  250. height: auto;
  251. border-radius: 45rpx;
  252. color: #07C160;
  253. border-color: #07C160;
  254. padding: 25rpx 0;
  255. box-sizing: border-box;
  256. font-size: 28rpx;
  257. line-height: 1;
  258. margin: 0;
  259. &-confirm {
  260. background-color: #07C160;
  261. color: #FFFFFF;
  262. }
  263. & + & {
  264. margin-top: 34rpx;
  265. }
  266. }
  267. </style>