edit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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" name="2" multiple
  7. :maxCount="1">
  8. <image style='width:680rpx;height:417rpx;' 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" name="3" multiple
  13. :maxCount="1">
  14. <image style='width:680rpx;height:417rpx;' 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" 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" name="5" multiple
  89. :maxCount="6">
  90. </u-upload>
  91. </u-form-item>
  92. </u--form>
  93. <view class="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. export default {
  105. data() {
  106. return {
  107. content:'确定提交入驻信息?',
  108. isSubmit:false,
  109. form:{
  110. commonId:uni.getStorageSync("userInfo").id,
  111. mainBody:'商铺',
  112. lookFlag:0,
  113. startDate:'',
  114. city: '',
  115. area: '',
  116. province: '',
  117. location: '',
  118. detailedAddress: '',
  119. businessLicense:'',
  120. operateCertificate:'',
  121. coverImage:'',
  122. indoorImage:'',
  123. timesection:'09:00~21:00',
  124. startDate:'09:00',
  125. endDate:'21:00',
  126. operateCertificateDate:'',
  127. },
  128. indoorImageArray:[],
  129. tips:'发送验证码',
  130. startDate:'',
  131. show:false,
  132. foodId:'',
  133. labelList:[{value:''},{value:''}],
  134. fileList2:[],
  135. fileList3:[],
  136. fileList4:[],
  137. fileList5:[],
  138. }
  139. },
  140. onLoad(options) {
  141. this.foodId=options.foodId
  142. that = this
  143. },
  144. onShow(){
  145. this.$request.baseRequest('admin.tourism.foodInfo', 'get', {
  146. id:this.foodId
  147. }, failres => {
  148. uni.showToast({
  149. icon: "none",
  150. title: failres.errmsg,
  151. duration: 3000
  152. });
  153. uni.hideLoading()
  154. }).then(res => {
  155. console.log(res.data)
  156. this.form=res.data
  157. this.fileList2=[{url:this.form.businessLicense}]
  158. this.fileList3=[{url:this.form.operateCertificate}]
  159. this.fileList4=[{url:this.form.coverImage}]
  160. this.fileList5=[]
  161. if(this.form.indoorImage){
  162. var arr=this.form.indoorImage.split(',')
  163. for(var i=0;i<arr.length;i++){
  164. if(arr[i]!=''){
  165. this.fileList5.push({url:arr[i]})
  166. }
  167. }
  168. }
  169. if(this.form.label){
  170. this.labelList=[]
  171. var label=this.form.label.split(',')
  172. for(var i=0;i<label.length;i++){
  173. if(arr[i]!=''){
  174. this.labelList.push({value:label[i]})
  175. }
  176. }
  177. }else{
  178. this.labelList=[{value:''},{value:''}]
  179. }
  180. })
  181. },
  182. methods: {
  183. submit(){
  184. if(this.labelList.length>0){
  185. var arr=[]
  186. for(var i=0;i<this.labelList.length;i++){
  187. if(!this.labelList[i].value){
  188. uni.showToast({
  189. icon: "none",
  190. title: '标签请输入内容!',
  191. duration: 3000
  192. });
  193. return
  194. }
  195. if(this.labelList[i].value.length>5){
  196. uni.showToast({
  197. icon: "none",
  198. title: '标签最多5个字!',
  199. duration: 3000
  200. });
  201. return
  202. }
  203. arr.push(this.labelList[i].value)
  204. }
  205. this.form.label=arr.toString()
  206. }
  207. uni.showModal({
  208. title: '提示',
  209. content: '确定提交入驻信息?',
  210. success (res) {
  211. if (res.confirm) {
  212. that.$u.debounce(that.confirmSubmit, 500)
  213. } else if (res.cancel) {
  214. console.log('用户点击取消')
  215. }
  216. }
  217. })
  218. },
  219. confirmSubmit() {
  220. uni.showLoading({
  221. title: '加载中',
  222. mask: true
  223. })
  224. this.form.status = '审核中'
  225. this.$request.baseRequest('admin.tourism.foodInfo', 'update', {
  226. foodInfo: JSON.stringify(this.form)
  227. }, failres => {
  228. uni.showToast({
  229. icon: "none",
  230. title: failres.errmsg,
  231. duration: 3000
  232. });
  233. uni.hideLoading()
  234. }).then(res => {
  235. this.isSubmit = false
  236. uni.showToast({
  237. icon: "success",
  238. title: '提交成功,请等待平台审核',
  239. duration: 2000
  240. });
  241. uni.navigateBack()
  242. })
  243. },
  244. concel(e){
  245. this.show=false
  246. console.log(e)
  247. },
  248. confrim(e){
  249. console.log(e)
  250. this.show=false
  251. this.form.timesection=e.time
  252. this.form.startDate=e.start
  253. this.form.endDate=e.end
  254. },
  255. selectTime(){
  256. this.show=true
  257. },
  258. addLabel(){
  259. if(this.labelList.length>=4){
  260. uni.showToast({
  261. icon: "success",
  262. title: '最多4个标签!',
  263. duration: 2000
  264. });
  265. return
  266. }
  267. this.labelList.push({value:''})
  268. },
  269. codeChange(text) {
  270. this.tips = text;
  271. },
  272. getCode() {
  273. if(!this.form.operaterPhone){
  274. uni.showToast({
  275. icon: "none",
  276. title: '请输入手机号再获取验证码!',
  277. duration: 2000
  278. });
  279. return
  280. }
  281. if (this.$refs.uCode.canGetCode) {
  282. // 模拟向后端请求验证码
  283. uni.showLoading({
  284. title: '正在获取验证码'
  285. })
  286. this.$request.baseRequest('user', 'sendVerifyCode', {
  287. phone: this.form.operaterPhone
  288. }, failres => {
  289. uni.showToast({
  290. icon: "none",
  291. title: failres.errmsg,
  292. duration: 3000
  293. });
  294. uni.hideLoading()
  295. }).then(res => {
  296. })
  297. setTimeout(() => {
  298. uni.hideLoading();
  299. // 这里此提示会被this.start()方法中的提示覆盖
  300. // 通知验证码组件内部开始倒计时
  301. this.$refs.uCode.start();
  302. }, 2000);
  303. } else {
  304. uni.showToast({
  305. icon: "success",
  306. title: '提交成功!',
  307. duration: 2000
  308. });
  309. }
  310. },
  311. confirm(e){
  312. this.form.operateCertificateDate = e.fulldate
  313. this.$forceUpdate()
  314. console.log(e)
  315. },
  316. openjyxkz(){
  317. this.$refs.calendar.open();
  318. },
  319. placeSelect() {
  320. uni.chooseLocation({
  321. success: function(res) {
  322. console.log(res);
  323. that.form.location = res.latitude + ',' + res.longitude
  324. let _address = that.$helper.formatLocation(res.address)
  325. console.log(_address)
  326. that.form.province = _address.Province
  327. that.form.city = _address.City
  328. that.form.area = _address.Country
  329. that.form.detailedAddress = _address.Village
  330. that.$forceUpdate()
  331. }
  332. });
  333. },
  334. hideKeyboard() {
  335. uni.hideKeyboard()
  336. },
  337. // 删除图片
  338. deletePic(event,status) {
  339. this[`fileList${event.name}`].splice(event.index, 1)
  340. that.indoorImageArray.splice(event.index, 1)
  341. that.form.indoorImage =that.indoorImageArray.toString()
  342. },
  343. // 新增图片
  344. async afterRead(event,status) {
  345. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  346. let lists = [].concat(event.file)
  347. let fileListLen = this[`fileList${event.name}`].length
  348. lists.map((item) => {
  349. this[`fileList${event.name}`].push({
  350. ...item,
  351. status: 'uploading',
  352. message: '上传中'
  353. })
  354. })
  355. for (let i = 0; i < lists.length; i++) {
  356. const result = await this.uploadFilePromise(lists[i].url,status)
  357. let item = this[`fileList${event.name}`][fileListLen]
  358. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  359. status: 'success',
  360. message: '',
  361. url: result
  362. }))
  363. fileListLen++
  364. console.log(that.form, this[`fileList${event.name}`])
  365. }
  366. },
  367. uploadFilePromise(res,status) {
  368. return new Promise((resolve, reject) => {
  369. uploadImage(res, 'cardImages/',
  370. result => {
  371. if(status==1){
  372. that.form.businessLicense = result
  373. }else if(status==2){
  374. that.form.operateCertificate = result
  375. }else if(status==3){
  376. that.form.coverImage = result
  377. }else if(status==4){
  378. that.indoorImageArray.push(result)
  379. that.form.indoorImage =that.indoorImageArray.toString()
  380. }
  381. resolve(res)
  382. }
  383. )
  384. })
  385. },
  386. }
  387. }
  388. </script>
  389. <style lang='scss' scoped>
  390. .wrap{
  391. padding:20rpx;
  392. }
  393. .icon_merchants_enterjianshao{
  394. margin-left:10rpx;
  395. font-size:50rpx;
  396. color:#666;
  397. }
  398. .add_label,.get_code{
  399. background: #5F7DE9;
  400. color: #fff;
  401. padding: 10rpx 20rpx;
  402. border-radius: 10rpx;
  403. font-size: 26rpx;
  404. }
  405. </style>