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

228 lines
4.7 KiB

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