hotel.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. <uni-calendar
  12. :insert="false"
  13. :lunar="true"
  14. ref="calendar"
  15. :start-date="startDate"
  16. @confirm="confirm"
  17. />
  18. <u-form-item labelWidth='150' labelPosition='left' label="酒店名称">
  19. <u-input inputAlign='right' border='none' placeholder='输入酒店名称' v-model="form.hotelName" />
  20. </u-form-item>
  21. <u-form-item labelWidth='80' labelPosition='left' @click='placeSelect(),hideKeyboard()' label="店铺位置">
  22. <view style='text-align:right;' v-if="form.province">{{ form.province }}{{ form.city }}{{ form.area }}</view>
  23. <view style='text-align:right;' v-else>
  24. <text style='text-align:right;'>选择位置 </text>
  25. <image src="@/static/image/yjt.png" mode=""
  26. style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image>
  27. </view>
  28. </u-form-item>
  29. <u-form-item labelWidth='80' labelPosition='left' label="详细地址">
  30. <u-input inputAlign='right' maxlength="15" border='none' placeholder='输入详细地址,不超过15个字' v-model="form.detailedAddress" />
  31. </u-form-item>
  32. <u-form-item labelWidth='150' labelPosition='left' label="法人姓名">
  33. <u-input inputAlign='right' border='none' placeholder='输入法人姓名' v-model="form.legalName" />
  34. </u-form-item>
  35. <u-form-item labelWidth='150' labelPosition='left' label="联系人">
  36. <u-input inputAlign='right' border='none' placeholder='输入联系人姓名' v-model="form.realname" />
  37. </u-form-item>
  38. <u-form-item labelWidth='150' labelPosition='left' label="手机号">
  39. <u-input inputAlign='right' border='none' placeholder='输入手机号' v-model="form.phone" />
  40. </u-form-item>
  41. <u-form-item labelWidth='150' labelPosition='left' label="验证码">
  42. <u-input inputAlign='right' border='none' placeholder='输入验证码' v-model="form.verifyCode" >
  43. <template slot="suffix">
  44. <u-code ref="uCode"
  45. @change="codeChange"
  46. seconds="60"
  47. changeText="X秒重新获取"
  48. ></u-code>
  49. <view class='get_code' @click='getCode'>{{tips}}</view>
  50. </template>
  51. </u-input>
  52. </u-form-item>
  53. </u-form-item>
  54. <u-form-item labelWidth='150' labelPosition='left' label="酒店座机(选填)">
  55. <u-input inputAlign='right' border='none' placeholder='输入座机号' v-model="form.landlinePhone" />
  56. </u-form-item>
  57. <u-form-item>
  58. <view class="flex service align-center">
  59. <view @click='' :class='consentStatus?"icon_merchants_entergouxuan":"icon_merchants_enterweigouxuan"' class="iconfont_no"></view>
  60. 我已阅读并同意
  61. <navigator
  62. url="/pageA/webview?can_share=false&url=https://liangxin.zthymaoyi.com/userAgreement.html"
  63. class="path" hover-class="navigator-hover">《酒店入驻协议》</navigator>的相关规定
  64. </view>
  65. </u-form-item>
  66. </u--form>
  67. <view class="footer">
  68. <button @click='submit' class="submit">提交</button>
  69. </view>
  70. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  71. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. var that
  77. import uploadImage from '@/components/ossutil/uploadFile.js';
  78. export default {
  79. data() {
  80. return {
  81. form:{
  82. commonId:uni.getStorageSync("userInfo").id,
  83. type:"2",
  84. },
  85. consentStatus:false,
  86. tips:'发送验证码',
  87. startDate:'',
  88. isSubmit:false,
  89. fileList2:[],
  90. content:'确定提交入驻信息',
  91. }
  92. },
  93. onLoad() {
  94. that = this
  95. },
  96. onShow(){
  97. var date = new Date().toISOString().slice(0, 10)
  98. this.startDate=date
  99. },
  100. methods: {
  101. codeChange(text) {
  102. this.tips = text;
  103. },
  104. getCode() {
  105. if(!this.form.phone){
  106. uni.showToast({
  107. icon: "none",
  108. title: '请输入手机号再获取验证码!',
  109. duration: 2000
  110. });
  111. return
  112. }
  113. if (this.$refs.uCode.canGetCode) {
  114. // 模拟向后端请求验证码
  115. uni.showLoading({
  116. title: '正在获取验证码'
  117. })
  118. this.$request.baseRequest('user', 'sendVerifyCode', {
  119. phone: this.form.phone
  120. }, failres => {
  121. uni.showToast({
  122. icon: "none",
  123. title: failres.errmsg,
  124. duration: 3000
  125. });
  126. uni.hideLoading()
  127. }).then(res => {
  128. })
  129. setTimeout(() => {
  130. uni.hideLoading();
  131. // 这里此提示会被this.start()方法中的提示覆盖
  132. // 通知验证码组件内部开始倒计时
  133. this.$refs.uCode.start();
  134. }, 2000);
  135. } else {
  136. uni.showToast({
  137. icon: "success",
  138. title: '提交成功!',
  139. duration: 2000
  140. });
  141. }
  142. },
  143. submit(){
  144. this.isSubmit = true
  145. },
  146. placeSelect() {
  147. uni.chooseLocation({
  148. success: function(res) {
  149. console.log(res);
  150. that.form.location = res.latitude + ',' + res.longitude
  151. let _address = that.$helper.formatLocation(res.address)
  152. console.log(_address)
  153. that.form.province = _address.Province
  154. that.form.city = _address.City
  155. that.form.area = _address.Country
  156. that.form.detailedAddress = _address.Village
  157. that.$forceUpdate()
  158. }
  159. });
  160. },
  161. hideKeyboard() {
  162. uni.hideKeyboard()
  163. },
  164. confirmSubmit(){
  165. uni.showLoading({
  166. title: '加载中',
  167. mask: true
  168. })
  169. this.$request.baseRequest('admin.tourism.homestayInfo', 'add', {
  170. homestayInfo: JSON.stringify(this.form)
  171. }, failres => {
  172. uni.showToast({
  173. icon: "none",
  174. title: failres.errmsg,
  175. duration: 3000
  176. });
  177. uni.hideLoading()
  178. }).then(res => {
  179. this.isSubmit = false
  180. uni.showToast({
  181. icon: "success",
  182. title: '提交成功,请等待平台审核',
  183. duration: 2000
  184. });
  185. uni.navigateBack()
  186. })
  187. },
  188. // 删除图片
  189. deletePic(event,status) {
  190. this[`fileList${event.name}`].splice(event.index, 1)
  191. },
  192. // 新增图片
  193. async afterRead(event,status) {
  194. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  195. let lists = [].concat(event.file)
  196. let fileListLen = this[`fileList${event.name}`].length
  197. lists.map((item) => {
  198. this[`fileList${event.name}`].push({
  199. ...item,
  200. status: 'uploading',
  201. message: '上传中'
  202. })
  203. })
  204. for (let i = 0; i < lists.length; i++) {
  205. const result = await this.uploadFilePromise(lists[i].url,status)
  206. let item = this[`fileList${event.name}`][fileListLen]
  207. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  208. status: 'success',
  209. message: '',
  210. url: result
  211. }))
  212. fileListLen++
  213. console.log(that.form, this[`fileList${event.name}`])
  214. }
  215. },
  216. uploadFilePromise(res,status) {
  217. return new Promise((resolve, reject) => {
  218. uploadImage(res, 'cardImages/',
  219. result => {
  220. if(status==1){
  221. that.form.businessLicense = result
  222. }
  223. resolve(res)
  224. }
  225. )
  226. })
  227. },
  228. }
  229. }
  230. </script>
  231. <style lang='scss' scoped>
  232. .wrap{
  233. padding:20rpx;
  234. }
  235. .icon_merchants_enterjian1{
  236. margin-left:10rpx;
  237. font-size:50rpx;
  238. }
  239. .add_label,.get_code{
  240. background: #5F7DE9;
  241. color: #fff;
  242. padding: 10rpx 20rpx;
  243. border-radius: 10rpx;
  244. font-size: 26rpx;
  245. }
  246. .circle{
  247. margin:110rpx 0 20rpx 0;
  248. }
  249. .path {
  250. color: #2772FB;
  251. }
  252. .icon_merchants_enterweigouxuan{
  253. color:#999;
  254. }
  255. .icon_merchants_entergouxuan{
  256. color:#5F7DE9;
  257. }
  258. </style>