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

341 lines
7.2 KiB

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