酒店桌布为微信小程序
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.

231 lines
4.8 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
  1. <template>
  2. <view class='updateUserInfo'>
  3. <!--顶部导航栏-->
  4. <navbar leftClick @leftClick="$utils.navigateBack" title="修改个人信息" />
  5. <!--主页面-->
  6. <view class="frame">
  7. <view class="headImage">
  8. <view style="" class="key">头像</view>
  9. <button style="" class="value" @chooseavatar="onChooseAvatar" open-type="chooseAvatar">
  10. <image
  11. :src="form.headImage" v-if="form.headImage"
  12. style="width: 100%;height: 100%" mode="aspectFill">
  13. </image>
  14. <image src="/static/image/tabbar/6.png" v-else style="width: 100%;height: 100%" mode="aspectFill">
  15. </image>
  16. </button>
  17. </view>
  18. <view class="item">
  19. <view class="label">昵称</view>
  20. <view class="value">
  21. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  22. v-model="form.nickName" />
  23. </view>
  24. </view>
  25. <!-- <view class="item" @click="sexChange">
  26. <view class="label">性别</view>
  27. <view>{{form.sex}}</view>
  28. </view> -->
  29. <!-- <view class="item">
  30. <view class="label">联系方式</view>
  31. <view class="value">
  32. <uv-input v-model="form.phone" placeholder="联系方式" border="bottom" clearable></uv-input>
  33. </view>
  34. </view> -->
  35. </view>
  36. <!-- ActionSheet 操作菜单 -->
  37. <uv-action-sheet ref="actionSheet" :actions="sexList" title="性别" @select="select" @close="close">
  38. </uv-action-sheet>
  39. <!--确认修改个人信息按钮-->
  40. <button @click="confirmEditUserInfo" class="bottomBtn">
  41. 确认修改
  42. </button>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. mapState,
  48. } from 'vuex'
  49. export default {
  50. computed: {
  51. ...mapState(['userInfo']),
  52. },
  53. data() {
  54. return {
  55. form: {
  56. sex: '',
  57. nickName: '1',
  58. phone: '',
  59. headImage: '',
  60. },
  61. // itemUserImage: userInfo.headImage,
  62. fileList: [],
  63. sexList: [{
  64. name: '男',
  65. value: 1
  66. },
  67. {
  68. name: '女',
  69. value: 0
  70. },
  71. ],
  72. }
  73. },
  74. onLoad() {
  75. this.form.phone = this.userInfo.phone
  76. this.form.headImage = this.userInfo.headImage
  77. this.form.nickName = this.userInfo.nickName
  78. this.form.sex = this.userInfo.sex
  79. if (this.userInfo.sex == '' || this.userInfo.sex == null) {
  80. this.form.sex = '未知'
  81. }
  82. },
  83. methods: {
  84. onChooseAvatar(res) {
  85. let self = this
  86. console.log(res.target.avatarUrl, "res.target.avatarUrl");
  87. self.$Oss.ossUpload(res.target.avatarUrl)
  88. .then(url => {
  89. console.log(url, "url");
  90. self.form.headImage = url
  91. })
  92. },
  93. // 确认修改个人信息
  94. confirmEditUserInfo() {
  95. let self = this
  96. uni.createSelectorQuery().in(this)
  97. .select("#nickName")
  98. .fields({
  99. properties: ["value"],
  100. })
  101. .exec((res) => {
  102. const nickName = res?.[0]?.value
  103. self.form.nickName = nickName
  104. if (self.$utils.verificationAll(self.form, {
  105. headImage: '请选择头像',
  106. nickName: '请填写昵称'
  107. })) {
  108. return
  109. }
  110. self.$api('updateInfo', {
  111. headImg : self.form.headImage,
  112. nickname : self.form.nickName,
  113. }, res => {
  114. if (res.code == 200) {
  115. uni.redirectTo({
  116. url: '/pages/index/center'
  117. })
  118. }
  119. })
  120. })
  121. },
  122. sexChange() {
  123. this.$refs.actionSheet.open() //打开ActionSheet 操作菜单
  124. },
  125. // ActionSheet 操作菜单选中
  126. select(e) {
  127. console.log('选中该项:', e);
  128. this.form.sex = e.name
  129. this.$refs.actionSheet.close() //关闭操作菜单
  130. },
  131. // ActionSheet 操作菜单关闭
  132. close() {
  133. this.$refs.actionSheet.close() //关闭操作菜单
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. * {
  140. box-sizing: border-box;
  141. margin: 0;
  142. padding: 0;
  143. }
  144. .updateUserInfo {
  145. .frame {
  146. padding: 28rpx 28rpx 0 28rpx;
  147. .headImage {
  148. display: flex;
  149. // width: 100vw;
  150. padding: 20rpx;
  151. .key {
  152. width: 500rpx;
  153. display: flex;
  154. align-items: center;
  155. }
  156. .value {
  157. border-radius: 50rpx;
  158. border: 1px solid red;
  159. box-sizing: border-box;
  160. overflow: hidden;
  161. width: 100rpx;
  162. height: 100rpx;
  163. padding: 0;
  164. }
  165. }
  166. .item {
  167. display: flex;
  168. justify-content: space-between;
  169. // border-bottom: 1px solid #c9c9c9;
  170. margin-top: 20rpx;
  171. padding: 20rpx;
  172. .label {
  173. width: 50%;
  174. }
  175. .value {
  176. width: 50%;
  177. text-align: right;
  178. }
  179. }
  180. }
  181. }
  182. /deep/ .input__content {
  183. /deep/.uv-input__content__field-wrapper {
  184. border: 1px solid red;
  185. input {
  186. text-align: right;
  187. }
  188. }
  189. }
  190. /deep/ .uv-input__content__field-wrapper__field {
  191. text-align: right;
  192. }
  193. .bottomBtn {
  194. position: fixed;
  195. bottom: 5%;
  196. left: 10%;
  197. width: 80%;
  198. height: 80rpx;
  199. text-align: center;
  200. color: #ffffff;
  201. background: $uni-color;
  202. display: flex;
  203. justify-content: center;
  204. align-items: center;
  205. font-size: 30rpx;
  206. }
  207. </style>