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

413 lines
8.7 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months 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. <view class="line">
  75. <view class="">
  76. 手机号
  77. </view>
  78. <view class=""
  79. v-if="form.phone">
  80. <input placeholder="请输入手机号" style="text-align: right;"
  81. disabled
  82. v-model="form.phone" />
  83. </view>
  84. <view class=""
  85. v-else>
  86. <button
  87. class="getPhoneNumber"
  88. open-type="getPhoneNumber"
  89. @getphonenumber="getPhone">
  90. 获取电话号码
  91. </button>
  92. </view>
  93. </view>
  94. <uv-datetime-picker
  95. ref="datetimePicker"
  96. v-model="form.yearDate"
  97. mode="year"
  98. :minDate="minDate"
  99. :maxDate="maxDate">
  100. </uv-datetime-picker>
  101. <uv-picker ref="picker"
  102. :columns="columns"
  103. keyName="name"
  104. @confirm="confirmAddress"></uv-picker>
  105. <view class="btn" @click="submit">
  106. 确认
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. import { mapState } from 'vuex'
  112. import mixinsSex from '@/mixins/sex.js'
  113. export default {
  114. mixins : [mixinsSex],
  115. data() {
  116. return {
  117. form: {
  118. headImage: '',
  119. nickName: '',
  120. sex : '男',
  121. yearDate : this.$dayjs().add(-18, 'y').valueOf(),//默认满18岁
  122. address : '',
  123. phone : '',
  124. },
  125. maxDate : this.$dayjs().valueOf(),
  126. minDate : this.$dayjs().add(-100, 'y').valueOf(),
  127. // sex : [
  128. // {
  129. // value : '男',
  130. // icon : 'man',
  131. // actColor : '#5baaff',
  132. // },
  133. // {
  134. // value : '女',
  135. // icon : 'woman',
  136. // actColor : '#ff50b3',
  137. // },
  138. // ],
  139. columns : [],
  140. back : '',
  141. };
  142. },
  143. computed: {
  144. ...mapState(['cityList', 'userInfo']),
  145. },
  146. onLoad({back}) {
  147. this.back = back
  148. // this.$nextTick(() => {
  149. // this.form.headImage = this.userInfo.headImage || this.form.headImage
  150. // this.form.nickName = this.userInfo.nickName || this.form.nickName
  151. // this.form.sex = this.userInfo.sex || this.form.sex
  152. // this.form.yearDate = this.userInfo.yearDate || this.form.yearDate
  153. // this.form.address = this.userInfo.address || this.form.address
  154. // })
  155. },
  156. onShow() {
  157. this.getCityList()
  158. this.getUserInfo()
  159. },
  160. computed: {},
  161. methods: {
  162. getPhone(e){
  163. this.$api('bindPhone', {
  164. phoneCode : e.detail.code
  165. }, res => {
  166. if(res.code == 200){
  167. let phoneObj = JSON.parse(res.result)
  168. if(phoneObj.errmsg == 'ok'){
  169. this.form.phone = phoneObj.phone_info.phoneNumber
  170. }else{
  171. uni.showModal({
  172. title: phoneObj.errmsg
  173. })
  174. }
  175. console.log(phoneObj);
  176. }
  177. })
  178. },
  179. onChooseAvatar(res) {
  180. let self = this
  181. self.$Oss.ossUpload(res.target.avatarUrl)
  182. .then(url => {
  183. self.form.headImage = url
  184. })
  185. },
  186. sexClick(item){
  187. this.form.sex = item.value
  188. },
  189. confirmAddress(e){
  190. this.form.address = e.value[0].name
  191. },
  192. // 获取城市
  193. getCityList(){
  194. this.$api('getCityList', res => {
  195. if(res.code == 200){
  196. this.columns = [
  197. res.result
  198. ]
  199. }
  200. })
  201. },
  202. getUserInfo(){
  203. this.$api('getInfo', res => {
  204. if(res.code == 200){
  205. this.form.headImage = res.result.headImage || this.form.headImage
  206. this.form.nickName = res.result.nickName || this.form.nickName
  207. this.form.sex = res.result.sex || this.form.sex
  208. this.form.phone = res.result.phone || this.form.phone
  209. this.form.yearDate = res.result.yearDate &&
  210. this.$dayjs(res.result.yearDate + '-01-01').valueOf() || this.form.yearDate
  211. this.form.address = res.result.address || this.form.address
  212. }
  213. })
  214. },
  215. submit() {
  216. let self = this
  217. uni.createSelectorQuery().in(this)
  218. .select("#nickName")
  219. .fields({
  220. properties: ["value"],
  221. })
  222. .exec((res) => {
  223. const nickName = res?.[0]?.value
  224. self.form.nickName = nickName
  225. if (self.$utils.verificationAll(self.form, {
  226. headImage: '请选择头像',
  227. nickName: '请填写昵称',
  228. address: '请选择居住地址',
  229. phone: '请获取手机号',
  230. })) {
  231. return
  232. }
  233. let data = {
  234. ...self.form,
  235. yearDate : this.$dayjs(self.form.yearDate).format("YYYY")
  236. }
  237. self.$api('updateInfo', data, res => {
  238. if (res.code == 200) {
  239. uni.reLaunch({
  240. url:'/pages/index/index'
  241. })
  242. }
  243. })
  244. })
  245. },
  246. }
  247. }
  248. </script>
  249. <style lang="scss" scoped>
  250. .login {
  251. display: flex;
  252. flex-direction: column;
  253. justify-content: center;
  254. align-items: center;
  255. height: 100vh;
  256. background-color: #fff;
  257. overflow: hidden;
  258. .bg1{
  259. width: 700rpx;
  260. height: 700rpx;
  261. border-radius: 50%;
  262. background-color: #ffc0b333;
  263. position: absolute;
  264. right: -300rpx;
  265. top: -300rpx;
  266. }
  267. .title {
  268. line-height: 45rpx;
  269. font-weight: 900;
  270. padding-bottom: 100rpx;
  271. font-size: 40rpx;
  272. }
  273. .chooseAvatar {
  274. width: 100%;
  275. padding: 0 !important;
  276. margin: 0 !important;
  277. border: none;
  278. background-color: #fff !important;
  279. width: 220rpx;
  280. height: 220rpx;
  281. border-radius: 50%;
  282. image{
  283. width: 200rpx;
  284. height: 200rpx;
  285. border-radius: 50%;
  286. box-shadow: 0 0 10rpx 10rpx #00000012;
  287. margin: 10rpx;
  288. }
  289. }
  290. .chooseAvatar::after{
  291. border: none;
  292. padding: 0 !important;
  293. margin: 0 !important;
  294. }
  295. .nickname{
  296. background-color: #f7f7f7;
  297. width: 600rpx;
  298. height: 80rpx;
  299. text-align: center;
  300. border-radius: 40rpx;
  301. margin-top: 30rpx;
  302. }
  303. .line {
  304. display: flex;
  305. justify-content: space-between;
  306. align-items: center;
  307. background-color: #f7f7f7;
  308. width: 600rpx;
  309. height: 80rpx;
  310. padding: 0 30rpx;
  311. margin: 0 auto;
  312. border-radius: 40rpx;
  313. margin-top: 30rpx;
  314. box-sizing: border-box;
  315. .getPhoneNumber{
  316. // all: unset;
  317. display: flex;
  318. justify-content: center;
  319. align-items: center;
  320. // background: $uni-linear-gradient-btn-color;
  321. background: $uni-color;
  322. color: #fff;
  323. width: 200rpx;
  324. height: 60rpx;
  325. border-radius: 30rpx;
  326. font-size: 24rpx;
  327. }
  328. }
  329. .sexSelect{
  330. background-color: #f7f7f7;
  331. width: 600rpx;
  332. height: 80rpx;
  333. text-align: center;
  334. border-radius: 40rpx;
  335. margin-top: 30rpx;
  336. display: flex;
  337. align-items: center;
  338. font-size: 26rpx;
  339. line-height: 80rpx;
  340. overflow: hidden;
  341. &>view{
  342. flex: 1;
  343. display: flex;
  344. justify-content: center;
  345. align-content: center;
  346. height: 100%;
  347. }
  348. &>view:nth-child(1){
  349. border-right: 1px solid #000;
  350. }
  351. }
  352. .address{
  353. background-color: #f7f7f7;
  354. width: 600rpx;
  355. height: 80rpx;
  356. text-align: center;
  357. border-radius: 40rpx;
  358. margin-top: 30rpx;
  359. line-height: 80rpx;
  360. color: #555;
  361. }
  362. .btn {
  363. // background: $uni-linear-gradient-btn-color;
  364. background: $uni-color;
  365. color: #fff;
  366. width: 80%;
  367. padding: 20rpx 0;
  368. text-align: center;
  369. border-radius: 15rpx;
  370. margin-top: 10vh;
  371. }
  372. }
  373. </style>