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

222 lines
4.6 KiB

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