apply.vue 6.7 KB

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