hotel.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. userInfo:{},
  91. content:'确定提交入驻信息',
  92. }
  93. },
  94. onLoad() {
  95. that = this
  96. },
  97. onShow(){
  98. var date = new Date().toISOString().slice(0, 10)
  99. this.startDate=date
  100. },
  101. methods: {
  102. codeChange(text) {
  103. this.tips = text;
  104. },
  105. getCode() {
  106. if(!this.form.phone){
  107. uni.showToast({
  108. icon: "none",
  109. title: '请输入手机号再获取验证码!',
  110. duration: 2000
  111. });
  112. return
  113. }
  114. if (this.$refs.uCode.canGetCode) {
  115. // 模拟向后端请求验证码
  116. uni.showLoading({
  117. title: '正在获取验证码'
  118. })
  119. this.$request.baseRequest('user', 'sendVerifyCode', {
  120. phone: this.form.phone
  121. }, failres => {
  122. uni.showToast({
  123. icon: "none",
  124. title: failres.errmsg,
  125. duration: 3000
  126. });
  127. uni.hideLoading()
  128. }).then(res => {
  129. })
  130. setTimeout(() => {
  131. uni.hideLoading();
  132. // 这里此提示会被this.start()方法中的提示覆盖
  133. // 通知验证码组件内部开始倒计时
  134. this.$refs.uCode.start();
  135. }, 2000);
  136. } else {
  137. uni.showToast({
  138. icon: "success",
  139. title: '提交成功!',
  140. duration: 2000
  141. });
  142. }
  143. },
  144. submit(){
  145. uni.showModal({
  146. title: '提示',
  147. content: '确定提交入驻信息?',
  148. success (res) {
  149. if (res.confirm) {
  150. that.$u.debounce(that.confirmSubmit, 500)
  151. } else if (res.cancel) {
  152. console.log('用户点击取消')
  153. }
  154. }
  155. })
  156. },
  157. placeSelect() {
  158. uni.chooseLocation({
  159. success: function(res) {
  160. console.log(res);
  161. that.form.location = res.latitude + ',' + res.longitude
  162. let _address = that.$helper.formatLocation(res.address)
  163. console.log(_address)
  164. that.form.province = _address.Province
  165. that.form.city = _address.City
  166. that.form.area = _address.Country
  167. that.form.detailedAddress = _address.Village
  168. that.$forceUpdate()
  169. }
  170. });
  171. },
  172. hideKeyboard() {
  173. uni.hideKeyboard()
  174. },
  175. confirmSubmit(){
  176. uni.showLoading({
  177. title: '加载中',
  178. mask: true
  179. })
  180. this.$request.baseRequest('admin.tourism.homestayInfo', 'add', {
  181. homestayInfo: JSON.stringify(this.form)
  182. }, failres => {
  183. uni.showToast({
  184. icon: "none",
  185. title: failres.errmsg,
  186. duration: 3000
  187. });
  188. uni.hideLoading()
  189. }).then(res => {
  190. this.isSubmit = false
  191. uni.showToast({
  192. icon: "success",
  193. title: '提交成功,请等待平台审核',
  194. duration: 2000
  195. });
  196. this.userInfo=uni.getStorageSync("userInfo")
  197. this.userInfo.hotelEntry+=1
  198. uni.setStorageSync("userInfo",this.userInfo)
  199. uni.navigateBack()
  200. })
  201. },
  202. // 删除图片
  203. deletePic(event,status) {
  204. this[`fileList${event.name}`].splice(event.index, 1)
  205. },
  206. // 新增图片
  207. async afterRead(event,status) {
  208. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  209. let lists = [].concat(event.file)
  210. let fileListLen = this[`fileList${event.name}`].length
  211. lists.map((item) => {
  212. this[`fileList${event.name}`].push({
  213. ...item,
  214. status: 'uploading',
  215. message: '上传中'
  216. })
  217. })
  218. for (let i = 0; i < lists.length; i++) {
  219. const result = await this.uploadFilePromise(lists[i].url,status)
  220. let item = this[`fileList${event.name}`][fileListLen]
  221. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  222. status: 'success',
  223. message: '',
  224. url: result
  225. }))
  226. fileListLen++
  227. console.log(that.form, this[`fileList${event.name}`])
  228. }
  229. },
  230. uploadFilePromise(res,status) {
  231. return new Promise((resolve, reject) => {
  232. uploadImage(res, 'cardImages/',
  233. result => {
  234. if(status==1){
  235. that.form.businessLicense = result
  236. }
  237. resolve(res)
  238. }
  239. )
  240. })
  241. },
  242. }
  243. }
  244. </script>
  245. <style lang='scss' scoped>
  246. .wrap{
  247. padding:20rpx;
  248. }
  249. .icon_merchants_enterjian1{
  250. margin-left:10rpx;
  251. font-size:50rpx;
  252. }
  253. .add_label,.get_code{
  254. background: #5F7DE9;
  255. color: #fff;
  256. padding: 10rpx 20rpx;
  257. border-radius: 10rpx;
  258. font-size: 26rpx;
  259. }
  260. .circle{
  261. margin:110rpx 0 20rpx 0;
  262. }
  263. .path {
  264. color: #2772FB;
  265. }
  266. .icon_merchants_enterweigouxuan{
  267. color:#999;
  268. }
  269. .icon_merchants_entergouxuan{
  270. color:#5F7DE9;
  271. }
  272. </style>