cateringindustry.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <view class='content'>
  3. <view class='wrap'>
  4. <u--form ref="uForm">
  5. <u-form-item labelWidth='80' labelPosition='top' label="营业执照">
  6. <u-upload height='208' width='320' :fileList="fileList2" @afterRead="afterRead($event,1)" @delete="deletePic($event,1)" name="2" multiple
  7. :maxCount="1">
  8. <image style='width:594rpx;height:378rpx;' src="../../static/image/enter/yingyezhizhao.png" mode=""></image>
  9. </u-upload>
  10. </u-form-item>
  11. <u-form-item labelWidth='80' labelPosition='top' label="经营许可证">
  12. <u-upload height='208' width='320' :fileList="fileList3" @afterRead="afterRead($event,2)" @delete="deletePic($event,2)" name="3" multiple
  13. :maxCount="1">
  14. <image style='width:594rpx;height:378rpx;' src="../../static/image/enter/jingyingxukezheng.png" mode=""></image>
  15. </u-upload>
  16. </u-form-item>
  17. <u-form-item labelWidth='150' labelPosition='left' label="经营许可证有效期">
  18. <view style='text-align:right;' @click='openjyxkz'>{{form.operateCertificateDate?form.operateCertificateDate:'选择日期'}}<image src="@/static/image/yjt.png" mode=""
  19. style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image></view>
  20. </u-form-item>
  21. <uni-calendar
  22. :insert="false"
  23. :lunar="true"
  24. ref="calendar"
  25. :start-date="startDate"
  26. @confirm="confirm"
  27. />
  28. <u-form-item labelWidth='150' labelPosition='left' label="店铺名称">
  29. <u-input inputAlign='right' border='none' placeholder='输入店铺名称' v-model="form.shopNames" />
  30. </u-form-item>
  31. <u-form-item labelWidth='150' labelPosition='left' label="经营者">
  32. <u-input inputAlign='right' border='none' placeholder='输入经营者姓名' v-model="form.operater" />
  33. </u-form-item>
  34. <u-form-item labelWidth='150' labelPosition='left' label="经营者手机号">
  35. <u-input inputAlign='right' maxlength="15" border='none' placeholder='输入经营者手机号' v-model="form.operaterPhone" />
  36. </u-form-item>
  37. <u-form-item labelWidth='150' labelPosition='left' label="验证码">
  38. <u-input inputAlign='right' border='none' placeholder='输入验证码' v-model="form.verifyCode" >
  39. <template slot="suffix">
  40. <u-code ref="uCode"
  41. @change="codeChange"
  42. seconds="60"
  43. changeText="X秒重新获取"
  44. ></u-code>
  45. <view class='get_code' @click='getCode'>{{tips}}</view>
  46. </template>
  47. </u-input>
  48. </u-form-item>
  49. <u-form-item labelWidth='150' labelPosition='left' label="业务联系人(选填)">
  50. <u-input inputAlign='right' border='none' placeholder='输入联系人姓名' v-model="form.contacts" />
  51. </u-form-item>
  52. <u-form-item labelWidth='150' labelPosition='left' label="业务联系电话(选填)">
  53. <u-input inputAlign='right' maxlength="15" border='none' placeholder='输入联系电话' v-model="form.contactsPhone" />
  54. </u-form-item>
  55. <u-form-item labelWidth='80' labelPosition='left' @click='placeSelect(),hideKeyboard()' label="店铺位置">
  56. <view style='text-align:right;' v-if="form.province">{{ form.province }}{{ form.city }}{{ form.area }}</view>
  57. <view style='text-align:right;' v-else>
  58. <text style='text-align:right;'>选择位置 </text>
  59. <image src="@/static/image/yjt.png" mode=""
  60. style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image>
  61. </view>
  62. </u-form-item>
  63. <u-form-item labelWidth='80' labelPosition='left' label="详细地址">
  64. <u-input inputAlign='right' maxlength="15" border='none' placeholder='输入详细地址,不超过15个字' v-model="form.detailedAddress" />
  65. </u-form-item>
  66. <u-form-item labelWidth='150' labelPosition='left' label="营业时间">
  67. <view style='text-align:right;' @click='selectTime'>{{form.timesection}}<image src="@/static/image/yjt.png" mode=""
  68. style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image></view>
  69. </u-form-item>
  70. <smh-time-range :is-under='show' :time="['18','0','42']" @confrim="confrim" @cancel="cancel"></smh-time-range>
  71. <!-- label -->
  72. <view class='flex justify-space-between align-item-center'>
  73. <view>标签(2-4个,最多5个字)</view>
  74. <view class='add_label' @click='addLabel'>新增</view>
  75. </view>
  76. <view style='flex-wrap: wrap;' class='flex'>
  77. <view style='margin:10rpx;width:47%;' class='flex align-item-center' v-for='item in labelList'>
  78. <u-input inputAlign='right' placeholder='输入标签文字' v-model="item.value" />
  79. <view class="iconfont_no icon_merchants_enterjianshao"></view>
  80. </view>
  81. </view>
  82. <u-form-item labelWidth='240' labelPosition='top' label="门面及门头照片(1张,店名文字清晰)">
  83. <u-upload :fileList="fileList4" @afterRead="afterRead($event,3)" @delete="deletePic($event,3)" name="4" multiple
  84. :maxCount="1">
  85. </u-upload>
  86. </u-form-item>
  87. <u-form-item labelWidth='120' labelPosition='top' label="室内照片(1-6张)">
  88. <u-upload :fileList="fileList5" @afterRead="afterRead($event,4)" @delete="deletePic($event,4)" name="5" multiple
  89. :maxCount="6">
  90. </u-upload>
  91. </u-form-item>
  92. </u--form>
  93. <view class="mercharts_footer">
  94. <button @click='submit' class="submit">提交</button>
  95. </view>
  96. </view>
  97. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  98. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  99. </view>
  100. </template>
  101. <script>
  102. var that
  103. import uploadImage from '@/components/ossutil/uploadFile.js';
  104. import uniCalendar from '@/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue'
  105. export default {
  106. components: {
  107. "uniCalendar": uniCalendar
  108. },
  109. data() {
  110. return {
  111. content:'确定提交入驻信息?',
  112. isSubmit:false,
  113. form:{
  114. commonId:uni.getStorageSync("userInfo").id,
  115. mainBody:'商铺',
  116. lookFlag:0,
  117. startDate:'',
  118. city: '',
  119. area: '',
  120. province: '',
  121. location: '',
  122. detailedAddress: '',
  123. businessLicense:'',
  124. operateCertificate:'',
  125. coverImage:'',
  126. indoorImage:'',
  127. timesection:'09:00~21:00',
  128. startDate:'09:00',
  129. endDate:'21:00',
  130. operateCertificateDate:'',
  131. },
  132. indoorImageArray:[],
  133. tips:'发送验证码',
  134. startDate:'',
  135. show:false,
  136. labelList:[{value:''},{value:''}],
  137. fileList2:[],
  138. fileList3:[],
  139. fileList4:[],
  140. fileList5:[],
  141. }
  142. },
  143. onLoad() {
  144. that = this
  145. },
  146. onShow(){
  147. var date = new Date().toISOString().slice(0, 10)
  148. this.startDate=date
  149. console.log(date)
  150. },
  151. methods: {
  152. submit(){
  153. if(this.labelList.length>0){
  154. var arr=[]
  155. for(var i=0;i<this.labelList.length;i++){
  156. if(!this.labelList[i].value){
  157. uni.showToast({
  158. icon: "none",
  159. title: '标签请输入内容!',
  160. duration: 3000
  161. });
  162. return
  163. }
  164. if(this.labelList[i].value.length>5){
  165. uni.showToast({
  166. icon: "none",
  167. title: '标签最多5个字!',
  168. duration: 3000
  169. });
  170. return
  171. }
  172. arr.push(this.labelList[i].value)
  173. }
  174. this.form.label=arr.toString()
  175. }
  176. uni.showModal({
  177. title: '提示',
  178. content: '确定提交入驻信息?',
  179. success (res) {
  180. if (res.confirm) {
  181. that.$u.debounce(confirmSubmit, 500)
  182. } else if (res.cancel) {
  183. console.log('用户点击取消')
  184. }
  185. }
  186. })
  187. },
  188. confirmSubmit() {
  189. uni.showLoading({
  190. title: '加载中',
  191. mask: true
  192. })
  193. this.$request.baseRequest('admin.tourism.foodInfo', 'add', {
  194. foodInfo: JSON.stringify(this.form)
  195. }, failres => {
  196. uni.showToast({
  197. icon: "none",
  198. title: failres.errmsg,
  199. duration: 3000
  200. });
  201. uni.hideLoading()
  202. }).then(res => {
  203. this.isSubmit = false
  204. uni.showToast({
  205. icon: "success",
  206. title: '提交成功,请等待平台审核',
  207. duration: 2000
  208. });
  209. that.indoorImageArray=[]
  210. uni.navigateBack()
  211. })
  212. },
  213. concel(e){
  214. this.show=false
  215. console.log(e)
  216. },
  217. confrim(e){
  218. console.log(e)
  219. this.show=false
  220. this.form.timesection=e.time
  221. this.form.startDate=e.start
  222. this.form.endDate=e.end
  223. },
  224. selectTime(){
  225. this.show=true
  226. },
  227. addLabel(){
  228. if(this.labelList.length>=4){
  229. uni.showToast({
  230. icon: "success",
  231. title: '最多4个标签!',
  232. duration: 2000
  233. });
  234. return
  235. }
  236. this.labelList.push({value:''})
  237. },
  238. codeChange(text) {
  239. this.tips = text;
  240. },
  241. getCode() {
  242. if(!this.form.operaterPhone){
  243. uni.showToast({
  244. icon: "none",
  245. title: '请输入手机号再获取验证码!',
  246. duration: 2000
  247. });
  248. return
  249. }
  250. if (this.$refs.uCode.canGetCode) {
  251. // 模拟向后端请求验证码
  252. uni.showLoading({
  253. title: '正在获取验证码'
  254. })
  255. this.$request.baseRequest('user', 'sendVerifyCode', {
  256. phone: this.form.operaterPhone
  257. }, failres => {
  258. uni.showToast({
  259. icon: "none",
  260. title: failres.errmsg,
  261. duration: 3000
  262. });
  263. uni.hideLoading()
  264. }).then(res => {
  265. })
  266. setTimeout(() => {
  267. uni.hideLoading();
  268. // 这里此提示会被this.start()方法中的提示覆盖
  269. // 通知验证码组件内部开始倒计时
  270. this.$refs.uCode.start();
  271. }, 2000);
  272. } else {
  273. uni.showToast({
  274. icon: "success",
  275. title: '提交成功!',
  276. duration: 2000
  277. });
  278. }
  279. },
  280. confirm(e){
  281. this.form.operateCertificateDate = e.fulldate
  282. this.$forceUpdate()
  283. console.log(e)
  284. },
  285. openjyxkz(){
  286. this.$refs.calendar.open();
  287. },
  288. placeSelect() {
  289. uni.chooseLocation({
  290. success: function(res) {
  291. console.log(res);
  292. that.form.location = res.latitude + ',' + res.longitude
  293. let _address = that.$helper.formatLocation(res.address)
  294. console.log(_address)
  295. that.form.province = _address.Province
  296. that.form.city = _address.City
  297. that.form.area = _address.Country
  298. that.form.detailedAddress = _address.Village
  299. that.$forceUpdate()
  300. }
  301. });
  302. },
  303. hideKeyboard() {
  304. uni.hideKeyboard()
  305. },
  306. // 删除图片
  307. deletePic(event,status) {
  308. this[`fileList${event.name}`].splice(event.index, 1)
  309. that.indoorImageArray.splice(event.index, 1)
  310. that.form.indoorImage =that.indoorImageArray.toString()
  311. },
  312. // 新增图片
  313. async afterRead(event,status) {
  314. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  315. let lists = [].concat(event.file)
  316. let fileListLen = this[`fileList${event.name}`].length
  317. lists.map((item) => {
  318. this[`fileList${event.name}`].push({
  319. ...item,
  320. status: 'uploading',
  321. message: '上传中'
  322. })
  323. })
  324. for (let i = 0; i < lists.length; i++) {
  325. const result = await this.uploadFilePromise(lists[i].url,status)
  326. let item = this[`fileList${event.name}`][fileListLen]
  327. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  328. status: 'success',
  329. message: '',
  330. url: result
  331. }))
  332. fileListLen++
  333. console.log(that.form, this[`fileList${event.name}`])
  334. }
  335. },
  336. uploadFilePromise(res,status) {
  337. return new Promise((resolve, reject) => {
  338. uploadImage(res, 'cardImages/',
  339. result => {
  340. if(status==1){
  341. that.form.businessLicense = result
  342. }else if(status==2){
  343. that.form.operateCertificate = result
  344. }else if(status==3){
  345. that.form.coverImage = result
  346. }else if(status==4){
  347. that.indoorImageArray.push(result)
  348. that.form.indoorImage =that.indoorImageArray.toString()
  349. }
  350. resolve(res)
  351. }
  352. )
  353. })
  354. },
  355. }
  356. }
  357. </script>
  358. <style lang='scss' scoped>
  359. .icon_merchants_enterjianshao{
  360. margin-left:10rpx;
  361. font-size:50rpx;
  362. color:#666;
  363. }
  364. .add_label,.get_code{
  365. background: #5F7DE9;
  366. color: #fff;
  367. padding: 10rpx 20rpx;
  368. border-radius: 10rpx;
  369. font-size: 26rpx;
  370. }
  371. </style>