瑶都万能墙
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.

449 lines
9.5 KiB

1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <view class="login">
  3. <!-- <view class="title">
  4. 瑶都万能墙
  5. </view>
  6. <view class="title">
  7. 申请获取你的头像昵称
  8. </view> -->
  9. <!-- <button class="chooseAvatar" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  10. <view class="line">
  11. <view class="">
  12. 头像
  13. </view>
  14. <view class="">
  15. <image :src="form.headImage" v-if="form.headImage" style="width: 60rpx;height: 60rpx;"
  16. mode=""></image>
  17. <image src="../static/auth/headImage.png" v-else style="width: 50rpx;height: 50rpx;" mode=""></image>
  18. </view>
  19. </view>
  20. </button>
  21. <view class="line">
  22. <view class="">
  23. 昵称
  24. </view>
  25. <view class="">
  26. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  27. v-model="form.nickName" />
  28. </view>
  29. </view> -->
  30. <view class="bg1"></view>
  31. <view class="title">
  32. 定制自己的形象
  33. </view>
  34. <view
  35. v-if="back"
  36. @click="$utils.navigateBack"
  37. style="position: absolute;top: 120rpx;left: 20rpx;">
  38. <uv-icon
  39. size="30rpx"
  40. color="#000"
  41. name="arrow-left"></uv-icon>
  42. </view>
  43. <button class="chooseAvatar"
  44. open-type="chooseAvatar"
  45. @chooseavatar="onChooseAvatar">
  46. <image :src="form.headImage"
  47. mode="aspectFill"></image>
  48. </button>
  49. <input type="nickname"
  50. placeholder="给自己起一个响亮的名字"
  51. class="nickname" id="nickName"
  52. v-model="form.nickName" />
  53. <view class="sexSelect">
  54. <view
  55. @click="sexClick(item)"
  56. v-for="(item, index) in sexList"
  57. :key="index"
  58. :style="{color : form.sex == item.value ? item.actColor : '#333'}">
  59. <uv-icon
  60. size="30rpx"
  61. :color="form.sex == item.value ? item.actColor : '#333'"
  62. :name="item.icon"></uv-icon>
  63. {{ item.value }}
  64. </view>
  65. </view>
  66. <view class="address"
  67. @click="$refs.datetimePicker.open()">
  68. 您出生于{{ $dayjs(form.yearDate).format("YYYY") }}
  69. </view>
  70. <view class="address"
  71. @click="$refs.picker.open()">
  72. {{ form.address || '请选择居住地址'}}
  73. </view>
  74. <input type="text"
  75. placeholder="初中学校名字(选填)"
  76. class="school-input"
  77. v-model="form.czSchool" />
  78. <input type="text"
  79. placeholder="高中学校名字(选填)"
  80. class="school-input"
  81. v-model="form.gzSchool" />
  82. <input type="email"
  83. placeholder="邮箱地址(选填)"
  84. class="school-input"
  85. v-model="form.mail" />
  86. <view class="line">
  87. <view class="">
  88. 手机号
  89. </view>
  90. <view class=""
  91. v-if="form.phone">
  92. <input placeholder="请输入手机号" style="text-align: right;"
  93. disabled
  94. v-model="form.phone" />
  95. </view>
  96. <view class=""
  97. v-else>
  98. <button
  99. class="getPhoneNumber"
  100. open-type="getPhoneNumber"
  101. @getphonenumber="getPhone">
  102. 获取电话号码
  103. </button>
  104. </view>
  105. </view>
  106. <uv-datetime-picker
  107. ref="datetimePicker"
  108. v-model="form.yearDate"
  109. mode="year"
  110. :minDate="minDate"
  111. :maxDate="maxDate">
  112. </uv-datetime-picker>
  113. <uv-picker ref="picker"
  114. :columns="columns"
  115. keyName="name"
  116. @confirm="confirmAddress"></uv-picker>
  117. <view class="btn" @click="submit">
  118. 确认
  119. </view>
  120. </view>
  121. </template>
  122. <script>
  123. import { mapState } from 'vuex'
  124. import mixinsSex from '@/mixins/sex.js'
  125. export default {
  126. mixins : [mixinsSex],
  127. data() {
  128. return {
  129. form: {
  130. headImage: '',
  131. nickName: '',
  132. sex : '男',
  133. yearDate : this.$dayjs().add(-18, 'y').valueOf(),//默认满18岁
  134. address : '',
  135. phone : '',
  136. czSchool: '',
  137. gzSchool: '',
  138. mail: '',
  139. },
  140. maxDate : this.$dayjs().valueOf(),
  141. minDate : this.$dayjs().add(-100, 'y').valueOf(),
  142. // sex : [
  143. // {
  144. // value : '男',
  145. // icon : 'man',
  146. // actColor : '#5baaff',
  147. // },
  148. // {
  149. // value : '女',
  150. // icon : 'woman',
  151. // actColor : '#ff50b3',
  152. // },
  153. // ],
  154. columns : [],
  155. back : '',
  156. };
  157. },
  158. computed: {
  159. ...mapState(['cityList', 'userInfo']),
  160. },
  161. onLoad({back}) {
  162. this.back = back
  163. // this.$nextTick(() => {
  164. // this.form.headImage = this.userInfo.headImage || this.form.headImage
  165. // this.form.nickName = this.userInfo.nickName || this.form.nickName
  166. // this.form.sex = this.userInfo.sex || this.form.sex
  167. // this.form.yearDate = this.userInfo.yearDate || this.form.yearDate
  168. // this.form.address = this.userInfo.address || this.form.address
  169. // })
  170. },
  171. onShow() {
  172. this.getCityList()
  173. this.getUserInfo()
  174. },
  175. computed: {},
  176. methods: {
  177. getPhone(e){
  178. this.$api('bindPhone', {
  179. phoneCode : e.detail.code
  180. }, res => {
  181. if(res.code == 200){
  182. let phoneObj = JSON.parse(res.result)
  183. if(phoneObj.errmsg == 'ok'){
  184. this.form.phone = phoneObj.phone_info.phoneNumber
  185. }else{
  186. uni.showModal({
  187. title: phoneObj.errmsg
  188. })
  189. }
  190. console.log(phoneObj);
  191. }
  192. })
  193. },
  194. onChooseAvatar(res) {
  195. let self = this
  196. self.$Oss.ossUpload(res.target.avatarUrl)
  197. .then(url => {
  198. self.form.headImage = url
  199. })
  200. },
  201. sexClick(item){
  202. this.form.sex = item.value
  203. },
  204. confirmAddress(e){
  205. this.form.address = e.value[0].name
  206. },
  207. // 获取城市
  208. getCityList(){
  209. this.$api('getCityList', res => {
  210. if(res.code == 200){
  211. this.columns = [
  212. res.result
  213. ]
  214. }
  215. })
  216. },
  217. getUserInfo(){
  218. this.$api('getInfo', res => {
  219. if(res.code == 200){
  220. this.form.headImage = res.result.headImage || this.form.headImage
  221. this.form.nickName = res.result.nickName || this.form.nickName
  222. this.form.sex = res.result.sex || this.form.sex
  223. this.form.phone = res.result.phone || this.form.phone
  224. this.form.yearDate = res.result.yearDate &&
  225. this.$dayjs(res.result.yearDate + '-01-01').valueOf() || this.form.yearDate
  226. this.form.address = res.result.address || this.form.address
  227. this.form.czSchool = res.result.czSchool || this.form.czSchool
  228. this.form.gzSchool = res.result.gzSchool || this.form.gzSchool
  229. this.form.mail = res.result.mail || this.form.mail
  230. }
  231. })
  232. },
  233. submit() {
  234. let self = this
  235. uni.createSelectorQuery().in(this)
  236. .select("#nickName")
  237. .fields({
  238. properties: ["value"],
  239. })
  240. .exec((res) => {
  241. const nickName = res?.[0]?.value
  242. self.form.nickName = nickName
  243. if (self.$utils.verificationAll(self.form, {
  244. headImage: '请选择头像',
  245. nickName: '请填写昵称',
  246. address: '请选择居住地址',
  247. phone: '请获取手机号',
  248. })) {
  249. return
  250. }
  251. let data = {
  252. ...self.form,
  253. yearDate : this.$dayjs(self.form.yearDate).format("YYYY")
  254. }
  255. self.$api('updateInfo', data, res => {
  256. if (res.code == 200) {
  257. uni.reLaunch({
  258. url:'/pages/index/index'
  259. })
  260. }
  261. })
  262. })
  263. },
  264. }
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .login {
  269. display: flex;
  270. flex-direction: column;
  271. justify-content: center;
  272. align-items: center;
  273. height: 100vh;
  274. background-color: #fff;
  275. overflow: hidden;
  276. .bg1{
  277. width: 700rpx;
  278. height: 700rpx;
  279. border-radius: 50%;
  280. background-color: #ffc0b333;
  281. position: absolute;
  282. right: -300rpx;
  283. top: -300rpx;
  284. }
  285. .title {
  286. line-height: 45rpx;
  287. font-weight: 900;
  288. padding-bottom: 100rpx;
  289. font-size: 40rpx;
  290. }
  291. .chooseAvatar {
  292. width: 100%;
  293. padding: 0 !important;
  294. margin: 0 !important;
  295. border: none;
  296. background-color: #fff !important;
  297. width: 220rpx;
  298. height: 220rpx;
  299. border-radius: 50%;
  300. image{
  301. width: 200rpx;
  302. height: 200rpx;
  303. border-radius: 50%;
  304. box-shadow: 0 0 10rpx 10rpx #00000012;
  305. margin: 10rpx;
  306. }
  307. }
  308. .chooseAvatar::after{
  309. border: none;
  310. padding: 0 !important;
  311. margin: 0 !important;
  312. }
  313. .nickname{
  314. background-color: #f7f7f7;
  315. width: 600rpx;
  316. height: 80rpx;
  317. text-align: center;
  318. border-radius: 40rpx;
  319. margin-top: 30rpx;
  320. }
  321. .line {
  322. display: flex;
  323. justify-content: space-between;
  324. align-items: center;
  325. background-color: #f7f7f7;
  326. width: 600rpx;
  327. height: 80rpx;
  328. padding: 0 30rpx;
  329. margin: 0 auto;
  330. border-radius: 40rpx;
  331. margin-top: 30rpx;
  332. box-sizing: border-box;
  333. .getPhoneNumber{
  334. // all: unset;
  335. display: flex;
  336. justify-content: center;
  337. align-items: center;
  338. // background: $uni-linear-gradient-btn-color;
  339. background: $uni-color;
  340. color: #fff;
  341. width: 200rpx;
  342. height: 60rpx;
  343. border-radius: 30rpx;
  344. font-size: 24rpx;
  345. }
  346. }
  347. .sexSelect{
  348. background-color: #f7f7f7;
  349. width: 600rpx;
  350. height: 80rpx;
  351. text-align: center;
  352. border-radius: 40rpx;
  353. margin-top: 30rpx;
  354. display: flex;
  355. align-items: center;
  356. font-size: 26rpx;
  357. line-height: 80rpx;
  358. overflow: hidden;
  359. &>view{
  360. flex: 1;
  361. display: flex;
  362. justify-content: center;
  363. align-content: center;
  364. height: 100%;
  365. }
  366. &>view:nth-child(1){
  367. border-right: 1px solid #000;
  368. }
  369. }
  370. .address{
  371. background-color: #f7f7f7;
  372. width: 600rpx;
  373. height: 80rpx;
  374. text-align: center;
  375. border-radius: 40rpx;
  376. margin-top: 30rpx;
  377. line-height: 80rpx;
  378. color: #555;
  379. }
  380. .school-input{
  381. background-color: #f7f7f7;
  382. width: 600rpx;
  383. height: 80rpx;
  384. text-align: center;
  385. border-radius: 40rpx;
  386. margin-top: 30rpx;
  387. padding: 0 30rpx;
  388. box-sizing: border-box;
  389. color: #333;
  390. }
  391. .btn {
  392. // background: $uni-linear-gradient-btn-color;
  393. background: $uni-color;
  394. color: #fff;
  395. width: 80%;
  396. padding: 20rpx 0;
  397. text-align: center;
  398. border-radius: 15rpx;
  399. margin-top: 10vh;
  400. }
  401. }
  402. </style>