editShopInformation.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class='content'>
  3. <view class='wrap'>
  4. <u--form ref="uForm">
  5. <u-form-item labelWidth='150' labelPosition='left' label="店铺名称">
  6. <u-input inputAlign='right' border='none' placeholder='输入店铺名称' v-model="currectData.shopNames" />
  7. </u-form-item>
  8. <u-form-item labelWidth='150' labelPosition='left' label="经营者">
  9. <u-input inputAlign='right' border='none' placeholder='输入经营者姓名' v-model="currectData.operater" />
  10. </u-form-item>
  11. <u-form-item labelWidth='150' labelPosition='left' label="经营者手机号">
  12. <u-input inputAlign='right' maxlength="15" border='none' placeholder='输入经营者手机号' v-model="currectData.operaterPhone" />
  13. </u-form-item>
  14. <u-form-item labelWidth='150' labelPosition='left' label="验证码">
  15. <u-input inputAlign='right' border='none' placeholder='输入验证码' v-model="currectData.verifyCode" >
  16. <template slot="suffix">
  17. <u-code ref="uCode"
  18. @change="codeChange"
  19. seconds="60"
  20. changeText="X秒重新获取"
  21. ></u-code>
  22. <view class='get_code' @click='getCode'>{{tips}}</view>
  23. </template>
  24. </u-input>
  25. </u-form-item>
  26. <u-form-item labelWidth='150' labelPosition='left' label="业务联系人(选填)">
  27. <u-input inputAlign='right' border='none' placeholder='输入联系人姓名' v-model="currectData.contacts" />
  28. </u-form-item>
  29. <u-form-item labelWidth='150' labelPosition='left' label="业务联系电话(选填)">
  30. <u-input inputAlign='right' maxlength="15" border='none' placeholder='输入联系电话' v-model="currectData.contactsPhone" />
  31. </u-form-item>
  32. <u-form-item labelWidth='80' labelPosition='left' @click='placeSelect(),hideKeyboard()' label="店铺位置">
  33. <view style='text-align:right;' v-if="currectData.province">{{ currectData.province }}{{ currectData.city }}{{ currectData.area }}</view>
  34. <view style='text-align:right;' v-else>
  35. <text style='text-align:right;'>选择位置 </text>
  36. <image src="@/static/image/yjt.png" mode=""
  37. style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image>
  38. </view>
  39. </u-form-item>
  40. <u-form-item labelWidth='80' labelPosition='left' label="详细地址">
  41. <u-input inputAlign='right' maxlength="15" border='none' placeholder='输入详细地址,不超过15个字' v-model="currectData.detailedAddress" />
  42. </u-form-item>
  43. </u--form>
  44. <view class="footer">
  45. <button @click='submit' class="submit">提交</button>
  46. </view>
  47. <u-modal :show="isSubmit" content='确定提交店铺信息?' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  48. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. var that
  54. export default {
  55. data() {
  56. return {
  57. currectData:{
  58. },
  59. isSubmit:false,
  60. tips:'发送验证码',
  61. }
  62. },
  63. onLoad() {
  64. that = this
  65. },
  66. onShow(){
  67. if(uni.getStorageSync('myCateringdustry')){
  68. this.currectData=JSON.parse(uni.getStorageSync('myCateringdustry'))
  69. }
  70. },
  71. methods: {
  72. placeSelect() {
  73. uni.chooseLocation({
  74. success: function(res) {
  75. console.log(res);
  76. that.currectData.location = res.latitude + ',' + res.longitude
  77. let _address = that.$helper.formatLocation(res.address)
  78. console.log(_address)
  79. that.currectData.province = _address.Province
  80. that.currectData.city = _address.City
  81. that.currectData.area = _address.Country
  82. that.currectData.detailedAddress = _address.Village
  83. that.$forceUpdate()
  84. }
  85. });
  86. },
  87. hideKeyboard() {
  88. uni.hideKeyboard()
  89. },
  90. codeChange(text) {
  91. this.tips = text;
  92. },
  93. getCode() {
  94. if(!this.currectData.operaterPhone){
  95. uni.showToast({
  96. icon: "none",
  97. title: '请输入手机号再获取验证码!',
  98. duration: 2000
  99. });
  100. return
  101. }
  102. if (this.$refs.uCode.canGetCode) {
  103. // 模拟向后端请求验证码
  104. uni.showLoading({
  105. title: '正在获取验证码'
  106. })
  107. this.$request.baseRequest('user', 'sendVerifyCode', {
  108. phone: this.currectData.operaterPhone
  109. }, failres => {
  110. uni.showToast({
  111. icon: "none",
  112. title: failres.errmsg,
  113. duration: 3000
  114. });
  115. uni.hideLoading()
  116. }).then(res => {
  117. })
  118. setTimeout(() => {
  119. uni.hideLoading();
  120. // 这里此提示会被this.start()方法中的提示覆盖
  121. // 通知验证码组件内部开始倒计时
  122. this.$refs.uCode.start();
  123. }, 2000);
  124. } else {
  125. uni.showToast({
  126. icon: "success",
  127. title: '提交成功!',
  128. duration: 2000
  129. });
  130. }
  131. },
  132. submit(){
  133. uni.showModal({
  134. title: '提示',
  135. content: '确定提交店铺信息?',
  136. success (res) {
  137. if (res.confirm) {
  138. that.$u.debounce(confirmSubmit, 500)
  139. } else if (res.cancel) {
  140. console.log('用户点击取消')
  141. }
  142. }
  143. })
  144. },
  145. confirmSubmit() {
  146. uni.showLoading({
  147. title: '加载中',
  148. mask: true
  149. })
  150. this.$request.baseRequest('admin.tourism.foodInfo', 'update', {
  151. foodInfo: JSON.stringify(this.currectData)
  152. }, failres => {
  153. uni.showToast({
  154. icon: "none",
  155. title: failres.errmsg,
  156. duration: 3000
  157. });
  158. uni.hideLoading()
  159. }).then(res => {
  160. this.isSubmit = false
  161. uni.showToast({
  162. icon: "success",
  163. title: '编辑店铺信息成功',
  164. duration: 2000
  165. });
  166. uni.setStorageSync('myCateringdustry',JSON.stringify(this.currectData))
  167. uni.navigateBack()
  168. })
  169. },
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .get_code{
  175. background: #5F7DE9;
  176. color: #fff;
  177. padding: 10rpx 20rpx;
  178. border-radius: 10rpx;
  179. font-size: 26rpx;
  180. }
  181. </style>