homestay.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class='content'>
  3. <view class='wrap'>
  4. <u--form ref="uForm">
  5. <u-form-item labelWidth='120' labelPosition='top' label="身份证头像面">
  6. <u-upload height='208' width='320' :fileList="fileList4" @afterRead="afterRead($event,1)" @delete="deletePic" name="4" multiple
  7. :maxCount="1">
  8. <view class="bgc">
  9. <image class='circle' style='width:123rpx;height:123rpx;' src="../../static/image/enter/camera.png" mode=""></image>
  10. <view>请上传头像面</view>
  11. </view>
  12. </u-upload>
  13. </u-form-item>
  14. <u-form-item labelWidth='120' labelPosition='top' label="身份证国徽面">
  15. <u-upload height='208' width='320' :fileList="fileList6" @afterRead="afterRead($event,2)" @delete="deletePic" name="6" multiple
  16. :maxCount="1">
  17. <view class="bgc1">
  18. <image class='circle' style='width:123rpx;height:123rpx;' src="../../static/image/enter/camera.png" mode=""></image>
  19. <view>请上传国徽面</view>
  20. </view>
  21. </u-upload>
  22. </u-form-item>
  23. <u-form-item labelWidth='120' labelPosition='left' label="身份证号码">
  24. <u-input inputAlign='right' border='none' placeholder='请输入身份证号码' v-model="form.personNo" />
  25. </u-form-item>
  26. <uni-calendar
  27. :insert="false"
  28. :lunar="true"
  29. ref="calendar"
  30. :start-date="startDate"
  31. @confirm="confirm"
  32. />
  33. <u-form-item labelWidth='150' labelPosition='left' label="姓名">
  34. <u-input inputAlign='right' border='none' placeholder='输入姓名' v-model="form.realname" />
  35. </u-form-item>
  36. <u-form-item labelWidth='150' labelPosition='left' label="手机号">
  37. <u-input inputAlign='right' border='none' placeholder='输入手机号' v-model="form.phone" />
  38. </u-form-item>
  39. <u-form-item labelWidth='150' labelPosition='left' label="验证码">
  40. <u-input inputAlign='right' border='none' placeholder='输入验证码' v-model="form.verifyCode" >
  41. <template slot="suffix">
  42. <u-code ref="uCode"
  43. @change="codeChange"
  44. seconds="60"
  45. changeText="X秒重新获取"
  46. ></u-code>
  47. <view class='get_code' @click='getCode'>{{tips}}</view>
  48. </template>
  49. </u-input>
  50. </u-form-item>
  51. </u-form-item>
  52. <u-form-item>
  53. <view class="flex service align-center">
  54. <view @click='' :class='consentStatus?"icon_merchants_entergouxuan":"icon_merchants_enterweigouxuan"' class="iconfont_no"></view>
  55. 我已阅读并同意
  56. <navigator
  57. url="/pageA/webview?can_share=false&url=https://liangxin.zthymaoyi.com/userAgreement.html"
  58. class="path" hover-class="navigator-hover">《民宿入驻协议》</navigator>的相关规定
  59. </view>
  60. </u-form-item>
  61. </u--form>
  62. <view class="footer">
  63. <button @click='submit' class="submit">提交</button>
  64. </view>
  65. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  66. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. var that
  72. import uploadImage from '@/components/ossutil/uploadFile.js';
  73. export default {
  74. data() {
  75. return {
  76. form:{
  77. commonId:uni.getStorageSync("userInfo").id,
  78. type:"1",
  79. },
  80. consentStatus:false,
  81. tips:'发送验证码',
  82. startDate:'',
  83. isSubmit:false,
  84. fileList4:[],
  85. fileList6:[],
  86. content:'确定提交入驻信息',
  87. }
  88. },
  89. onLoad() {
  90. that = this
  91. },
  92. onShow(){
  93. var date = new Date().toISOString().slice(0, 10)
  94. this.startDate=date
  95. },
  96. methods: {
  97. codeChange(text) {
  98. this.tips = text;
  99. },
  100. getCode() {
  101. if(!this.form.phone){
  102. uni.showToast({
  103. icon: "none",
  104. title: '请输入手机号再获取验证码!',
  105. duration: 2000
  106. });
  107. return
  108. }
  109. if (this.$refs.uCode.canGetCode) {
  110. // 模拟向后端请求验证码
  111. uni.showLoading({
  112. title: '正在获取验证码'
  113. })
  114. this.$request.baseRequest('user', 'sendVerifyCode', {
  115. phone: this.form.phone
  116. }, failres => {
  117. uni.showToast({
  118. icon: "none",
  119. title: failres.errmsg,
  120. duration: 3000
  121. });
  122. uni.hideLoading()
  123. }).then(res => {
  124. })
  125. setTimeout(() => {
  126. uni.hideLoading();
  127. // 这里此提示会被this.start()方法中的提示覆盖
  128. // 通知验证码组件内部开始倒计时
  129. this.$refs.uCode.start();
  130. }, 2000);
  131. } else {
  132. uni.showToast({
  133. icon: "success",
  134. title: '提交成功!',
  135. duration: 2000
  136. });
  137. }
  138. },
  139. submit(){
  140. this.isSubmit = true
  141. },
  142. confirmSubmit(){
  143. uni.showLoading({
  144. title: '加载中',
  145. mask: true
  146. })
  147. this.$request.baseRequest('admin.tourism.homestayInfo', 'add', {
  148. homestayInfo: JSON.stringify(this.form)
  149. }, failres => {
  150. uni.showToast({
  151. icon: "none",
  152. title: failres.errmsg,
  153. duration: 3000
  154. });
  155. uni.hideLoading()
  156. }).then(res => {
  157. this.isSubmit = false
  158. uni.showToast({
  159. icon: "success",
  160. title: '提交成功,请等待平台审核',
  161. duration: 2000
  162. });
  163. uni.navigateBack()
  164. })
  165. },
  166. // 删除图片
  167. deletePic(event,status) {
  168. this[`fileList${event.name}`].splice(event.index, 1)
  169. },
  170. // 新增图片
  171. async afterRead(event,status) {
  172. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  173. let lists = [].concat(event.file)
  174. let fileListLen = this[`fileList${event.name}`].length
  175. lists.map((item) => {
  176. this[`fileList${event.name}`].push({
  177. ...item,
  178. status: 'uploading',
  179. message: '上传中'
  180. })
  181. })
  182. for (let i = 0; i < lists.length; i++) {
  183. const result = await this.uploadFilePromise(lists[i].url,status)
  184. let item = this[`fileList${event.name}`][fileListLen]
  185. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  186. status: 'success',
  187. message: '',
  188. url: result
  189. }))
  190. fileListLen++
  191. console.log(that.form, this[`fileList${event.name}`])
  192. }
  193. },
  194. uploadFilePromise(res,status) {
  195. return new Promise((resolve, reject) => {
  196. uploadImage(res, 'cardImages/',
  197. result => {
  198. if(status==1){
  199. that.form.personImageFront = result
  200. uni.showLoading({
  201. title: '加载中',
  202. mask: true
  203. })
  204. that.$request.baseRequest('admin.tourism.productManagement', 'personShibie', {
  205. personImageFront: that.form.personImageFront
  206. }, failres => {
  207. uni.showToast({
  208. icon: "none",
  209. title: failres.errmsg,
  210. duration: 3000
  211. });
  212. uni.hideLoading()
  213. }).then(res => {
  214. console.log(res)
  215. uni.hideLoading()
  216. that.form.personNo=res.data.recPersonNo
  217. console.log(that.form)
  218. that.$forceUpdate()
  219. })
  220. }else if(status==2){
  221. that.form.personImageBack = 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. // 人像
  250. .bgc,.bgc1{
  251. width:672rpx;
  252. height:417rpx;
  253. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card2.png') no-repeat center;
  254. background-size: 100%;
  255. text-align:center;
  256. }
  257. // 国徽
  258. .bgc1{
  259. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card.png') no-repeat center;
  260. background-size: 100%;
  261. }
  262. .path {
  263. color: #2772FB;
  264. }
  265. .icon_merchants_enterweigouxuan{
  266. color:#999;
  267. }
  268. .icon_merchants_entergouxuan{
  269. color:#5F7DE9;
  270. }
  271. </style>