Info.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false">
  3. <view class="div seller-o2o-index">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="店铺设置" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="div main-content">
  14. <view class="div user-avatar">
  15. <uni-file-picker class="common-avatar" v-model="imageValue" fileMediatype="image" mode="grid" :limit="1"
  16. :auto-upload="false" @select="uploadAvatar"></uni-file-picker>
  17. </view>
  18. <flex-line class="field-line" :show-border="true"><text class="span field-name">主营商品</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="settings.store_mainbusiness" /></view></flex-line>
  19. <flex-line class="field-line" :show-border="true"><text class="span field-name">QQ</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="settings.store_qq" /></view></flex-line>
  20. <flex-line class="field-line" :show-border="true"><text class="span field-name">阿里旺旺</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="settings.store_ww" /></view></flex-line>
  21. <flex-line class="field-line" :show-border="true"><text class="span field-name">SEO关键</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="settings.store_keywords" /></view></flex-line>
  22. <flex-line class="field-line" :show-border="true"><text class="span field-name">SEO店铺</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="settings.store_description" /></view></flex-line>
  23. <flex-line class="field-line" :show-border="true"><text class="span field-name">店铺电话</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="settings.store_phone" /></view></flex-line>
  24. <view class="div pt-10 pb-10">
  25. <view class="div common-btn ds-button-large" @click="submit">保存</view>
  26. </view>
  27. </view>
  28. <tui-picture-cropper v-if="cropperOption.imgUrl" :width="cropperOption.autoCropWidth"
  29. :height="cropperOption.autoCropHeight" :imageUrl="cropperOption.img" @ready="cropReady" @cropper="useCrop" @back="cropBack">
  30. </tui-picture-cropper>
  31. </view>
  32. </seller-base>
  33. </template>
  34. <script>
  35. import {getFontSize} from '@/util/common'
  36. import TitleHeader from '../../TitleHeader'
  37. import SellerBase from '../SellerBase'
  38. import tuiPictureCropper from "@/components/thorui/tui-picture-cropper/tui-picture-cropper"
  39. import { uploadStoreImage, getStoreInfo, editStoreInfo } from '../../../api/sellerSetting'
  40. import flexLine from '../../flexLine'
  41. export default {
  42. name: 'SellerSettingInfo',
  43. data(){
  44. return {
  45. navHeight: 0,
  46. imageValue:[],
  47. screenWidth:0,
  48. cropperOption: {
  49. img: '',
  50. canMove: false,
  51. autoCrop: true,
  52. autoCropWidth: 100,
  53. autoCropHeight: 100,
  54. maxImgSize: 500,
  55. outputType: 'png'
  56. },
  57. store_avatar: '',
  58. store_avatar_url: '',
  59. settings: {}
  60. }
  61. },
  62. created: function () {
  63. getStoreInfo().then(res => {
  64. this.settings = res.result.store_info
  65. this.store_avatar = this.settings.store_avatar
  66. this.store_avatar_url = this.settings.store_avatar_url
  67. if (this.store_avatar) {
  68. this.imageValue = [{
  69. name: 'store_avatar',
  70. extname: 'jpg',
  71. url: this.store_avatar_url
  72. }]
  73. }
  74. }).catch(function (error) {
  75. uni.showToast({icon:'none',title: error.message})
  76. })
  77. },
  78. components:{
  79. TitleHeader,
  80. SellerBase,
  81. flexLine,
  82. tuiPictureCropper
  83. },
  84. computed:{
  85. fontSize(){
  86. return getFontSize()
  87. },
  88. },
  89. mounted(){
  90. // #ifdef MP-WEIXIN
  91. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  92. // #endif
  93. this.screenWidth=uni.getSystemInfoSync().screenWidth
  94. },
  95. methods:{
  96. showPopup(id){
  97. this.$refs[id].open()
  98. },
  99. hidePopup(id){
  100. this.$refs[id].close()
  101. },
  102. goBack(){uni.navigateBack({delta:1})},
  103. submit () {
  104. editStoreInfo(this.settings.store_qq, this.settings.store_ww, this.settings.store_phone, this.settings.store_mainbusiness, this.settings.store_keywords, this.settings.store_description, this.store_avatar).then(res => {
  105. uni.showToast({icon:'none',title: res.message})
  106. }).catch(function (error) {
  107. uni.showToast({icon:'none',title: error.message})
  108. })
  109. },
  110. uploadAvatar (event) {
  111. var file = event.tempFiles[0]
  112. var that = this
  113. that.cropperOption.imgUrl = file.path
  114. that.cropperOption.autoCropWidth = uni.getSystemInfoSync().windowWidth
  115. that.cropperOption.autoCropHeight = uni.getSystemInfoSync().windowWidth
  116. that.cropperOption.maxImgSize = uni.getSystemInfoSync().windowHeight - 40
  117. that.$forceUpdate()
  118. },
  119. useCrop (res) {
  120. var formdata = {
  121. filePath: res.url,
  122. name: 'store_avatar',
  123. id:'store_avatar'
  124. }
  125. uni.showLoading({ title: '加载中' })
  126. uploadStoreImage(formdata).then(res => {
  127. this.store_avatar = res.result.file_name
  128. this.store_avatar_url = res.result.file_path
  129. this.imageValue = [{
  130. name: 'store_avatar',
  131. extname: 'jpg',
  132. url: this.store_avatar_url
  133. }]
  134. this.cropperOption.imgUrl = ''
  135. this.$forceUpdate()
  136. uni.hideLoading()
  137. }).catch((error) => {
  138. uni.showToast({icon:'none',title: error.message})
  139. uni.hideLoading()
  140. this.cropperOption.imgUrl = ''
  141. this.$forceUpdate()
  142. })
  143. },
  144. cropReady() {
  145. this.cropperOption.img = this.cropperOption.imgUrl
  146. },
  147. cropBack(){
  148. this.cropperOption.imgUrl=''
  149. this.$forceUpdate()
  150. },
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .common-header{
  156. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  157. }
  158. .seller-o2o-index{background: #fff;}
  159. .main-content{background: #fff;padding:0 $pageSpace}
  160. .user-avatar {
  161. position: relative;
  162. margin: 2rem auto;
  163. text-align: center;
  164. }
  165. </style>