apply.vue 6.5 KB

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