apply.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view>
  3. <view class="cn">
  4. <u-steps :list="numList" mode="number" :current="num" active-color="#c74547"></u-steps>
  5. <u-subsection :list="subsection" :current="current" @change="section" button-color="#c74547" active-color="#ffffff"></u-subsection>
  6. <view class="info">
  7. <view class="form_group hr">
  8. <view class="lable">商铺名称</view>
  9. <input type="text" placeholder="请输入商铺名称" v-model="item.name" />
  10. </view>
  11. <view class="form_group hr">
  12. <view class="lable">商铺地址</view>
  13. <input type="text" placeholder="请输入商铺地址" v-model="item.addres" />
  14. <view class="dw icon" @click="wz(1)">&#xe64a;</view>
  15. </view>
  16. <view class="form_group hr">
  17. <view class="lable">地图坐标</view>
  18. <input type="number" placeholder="请在地图上选择坐标" @click="wz(2)" v-model="zb" :disabled="true" />
  19. </view>
  20. <view class="form_group hr">
  21. <view class="lable">老板名称</view>
  22. <input type="text" placeholder="请输入老板名称" v-model="item.bossName" />
  23. </view>
  24. <view class="form_group hr">
  25. <view class="lable">老板电话</view>
  26. <input type="number" placeholder="请输入老板电话" v-model="item.bossPhone" />
  27. </view>
  28. <view class="form_group"><view class="lable">商铺展示</view></view>
  29. <view class="pl5">
  30. <u-upload
  31. :ip="ip"
  32. :action="upload.action"
  33. :header="upload.header"
  34. :size-type="upload.size"
  35. :max-count="upload.count"
  36. :name="upload.name"
  37. :file-list="item.showPictures"
  38. :deletable="item.auditFlag != 1"
  39. :show-progress="item.auditFlag != 1"
  40. :custom-btn="item.auditFlag == 1"
  41. ref="uUpload"
  42. width="140"
  43. height="140"
  44. ></u-upload>
  45. </view>
  46. <view class="form_group"><view class="lable">商铺简介</view></view>
  47. <textarea placeholder="请输入商铺简介(200字以内)" v-model="item.briefContent" maxlength="200" />
  48. </view>
  49. <button class="btn" @click="up()" v-if="!item.auditFlag">申请开通</button>
  50. <button class="btn" @click="up()" v-if="item.auditFlag == 0">更新资料</button>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. ip: this.$http.urls.ip,
  59. subsection: [{ name: '商铺', value: 1 }, { name: '酒店', value: 2 }],
  60. numList: [{ name: '资料填写' }, { name: '资料审核' }, { name: '审核通过' }],
  61. num: 0,
  62. current: 0,
  63. item: { showPictures: [] },
  64. zb: '', //坐标
  65. upload: {
  66. header: { apiToken: this.$getUser().apiToken },
  67. name: 'img',
  68. action: this.$http.urls.uploadImg,
  69. size_type: 'compressed ',
  70. count: 5
  71. }
  72. };
  73. },
  74. onLoad(e) {
  75. if (e.item) {
  76. this.item = JSON.parse(e.item);
  77. if (this.item.lat) {
  78. this.zb = '纬度:' + this.item.lat + ' 经度:' + this.item.lng;
  79. }
  80. this.subsection.forEach((item, index) => {
  81. if (item.value == this.item.shopType) {
  82. this.current = index;
  83. }
  84. });
  85. this.item.shopType = this.subsection[this.current].value;
  86. if (this.item.auditFlag == 0) {
  87. this.num = 1;
  88. }
  89. if (this.item.auditFlag == 1) {
  90. this.num = 2;
  91. }
  92. }
  93. },
  94. methods: {
  95. section(current) {
  96. this.current = current;
  97. },
  98. //定位
  99. wz(index) {
  100. uni.chooseLocation({
  101. success: r => {
  102. if (index == 1) {
  103. this.item.addres = r.address;
  104. }
  105. this.zb = '纬度:' + r.latitude + ' 经度:' + r.longitude;
  106. this.item.lat = r.latitude;
  107. this.item.lng = r.longitude;
  108. this.$forceUpdate();
  109. }
  110. });
  111. },
  112. up() {
  113. this.item.showPictures = [];
  114. let files = this.$refs.uUpload.lists.filter(val => {
  115. return val.progress == 100;
  116. });
  117. files.forEach(item => {
  118. if (item.response) {
  119. this.item.showPictures.push({ url: item.response.fileName }); //获取上传成功的网络地址
  120. } else {
  121. this.item.showPictures.push({ url: item.url }); //原来的地址
  122. }
  123. });
  124. let rule = [
  125. { name: 'name', checkType: 'notnull', errorMsg: '请输入商铺名称' },
  126. { name: 'addres', checkType: 'notnull', errorMsg: '请输入商铺地址' },
  127. { name: 'bossName', checkType: 'notnull', errorMsg: '请输入老板名称' },
  128. { name: 'bossPhone', checkType: 'notnull', errorMsg: '请输入老板电话' },
  129. { name: 'lat', checkType: 'notnull', errorMsg: '请在地图上选择坐标' },
  130. { name: 'showPictures', checkType: 'notnull', errorMsg: '请上传至少1张展示图' }
  131. ];
  132. if (!this.$verify.check(this.item, rule)) {
  133. uni.showModal({ content: this.$verify.error, showCancel: false });
  134. return;
  135. }
  136. this.item.shopType = this.subsection[this.current].value;
  137. this.item.memberId = this.$getUser().memberId;
  138. this.item.showPictures = JSON.stringify(this.item.showPictures);
  139. this.$http.request({
  140. method: 'POST',
  141. url: this.item.shopId ? this.$http.urls.updateShop : this.$http.urls.shopApply,
  142. data: this.item,
  143. success: res => {
  144. uni.showToast({ title: '提交成功' });
  145. setTimeout(() => {
  146. uni.$emit('shop');
  147. uni.navigateBack();
  148. }, 700);
  149. }
  150. });
  151. }
  152. }
  153. };
  154. </script>
  155. <style lang="scss">
  156. .steps {
  157. text-align: center;
  158. margin-top: 20px;
  159. }
  160. .u-subsection {
  161. margin-top: 20px;
  162. }
  163. .cn {
  164. padding: 15px;
  165. .info {
  166. background-color: white;
  167. border-radius: 5px;
  168. margin-top: 10px;
  169. padding-bottom: 10px;
  170. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  171. .dw {
  172. top: 11px;
  173. font-size: 19px;
  174. right: 9px;
  175. position: absolute;
  176. }
  177. }
  178. textarea {
  179. margin-left: 17px;
  180. font-size: 14px;
  181. padding: 10px;
  182. width: 85%;
  183. height: 85px;
  184. border: 1px solid #f1f1f1;
  185. border-radius: 5px;
  186. }
  187. .btn {
  188. margin-top: 25px;
  189. }
  190. }
  191. </style>