hotel.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. uni.showModal({
  145. title: '提示',
  146. content: '确定提交入驻信息?',
  147. success (res) {
  148. if (res.confirm) {
  149. that.$u.debounce(confirmSubmit, 500)
  150. } else if (res.cancel) {
  151. console.log('用户点击取消')
  152. }
  153. }
  154. })
  155. },
  156. placeSelect() {
  157. uni.chooseLocation({
  158. success: function(res) {
  159. console.log(res);
  160. that.form.location = res.latitude + ',' + res.longitude
  161. let _address = that.$helper.formatLocation(res.address)
  162. console.log(_address)
  163. that.form.province = _address.Province
  164. that.form.city = _address.City
  165. that.form.area = _address.Country
  166. that.form.detailedAddress = _address.Village
  167. that.$forceUpdate()
  168. }
  169. });
  170. },
  171. hideKeyboard() {
  172. uni.hideKeyboard()
  173. },
  174. confirmSubmit(){
  175. uni.showLoading({
  176. title: '加载中',
  177. mask: true
  178. })
  179. this.$request.baseRequest('admin.tourism.homestayInfo', 'add', {
  180. homestayInfo: JSON.stringify(this.form)
  181. }, failres => {
  182. uni.showToast({
  183. icon: "none",
  184. title: failres.errmsg,
  185. duration: 3000
  186. });
  187. uni.hideLoading()
  188. }).then(res => {
  189. this.isSubmit = false
  190. uni.showToast({
  191. icon: "success",
  192. title: '提交成功,请等待平台审核',
  193. duration: 2000
  194. });
  195. uni.navigateBack()
  196. })
  197. },
  198. // 删除图片
  199. deletePic(event,status) {
  200. this[`fileList${event.name}`].splice(event.index, 1)
  201. },
  202. // 新增图片
  203. async afterRead(event,status) {
  204. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  205. let lists = [].concat(event.file)
  206. let fileListLen = this[`fileList${event.name}`].length
  207. lists.map((item) => {
  208. this[`fileList${event.name}`].push({
  209. ...item,
  210. status: 'uploading',
  211. message: '上传中'
  212. })
  213. })
  214. for (let i = 0; i < lists.length; i++) {
  215. const result = await this.uploadFilePromise(lists[i].url,status)
  216. let item = this[`fileList${event.name}`][fileListLen]
  217. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  218. status: 'success',
  219. message: '',
  220. url: result
  221. }))
  222. fileListLen++
  223. console.log(that.form, this[`fileList${event.name}`])
  224. }
  225. },
  226. uploadFilePromise(res,status) {
  227. return new Promise((resolve, reject) => {
  228. uploadImage(res, 'cardImages/',
  229. result => {
  230. if(status==1){
  231. that.form.businessLicense = result
  232. }
  233. resolve(res)
  234. }
  235. )
  236. })
  237. },
  238. }
  239. }
  240. </script>
  241. <style lang='scss' scoped>
  242. .wrap{
  243. padding:20rpx;
  244. }
  245. .icon_merchants_enterjian1{
  246. margin-left:10rpx;
  247. font-size:50rpx;
  248. }
  249. .add_label,.get_code{
  250. background: #5F7DE9;
  251. color: #fff;
  252. padding: 10rpx 20rpx;
  253. border-radius: 10rpx;
  254. font-size: 26rpx;
  255. }
  256. .circle{
  257. margin:110rpx 0 20rpx 0;
  258. }
  259. .path {
  260. color: #2772FB;
  261. }
  262. .icon_merchants_enterweigouxuan{
  263. color:#999;
  264. }
  265. .icon_merchants_entergouxuan{
  266. color:#5F7DE9;
  267. }
  268. </style>