homestay.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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='consentStatus=!consentStatus' :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="mercharts_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. uni.showModal({
  141. title: '提示',
  142. content: '确定提交入驻信息?',
  143. success (res) {
  144. if (res.confirm) {
  145. that.$u.debounce(confirmSubmit, 500)
  146. } else if (res.cancel) {
  147. console.log('用户点击取消')
  148. }
  149. }
  150. })
  151. },
  152. confirmSubmit(){
  153. uni.showLoading({
  154. title: '加载中',
  155. mask: true
  156. })
  157. this.$request.baseRequest('admin.tourism.homestayInfo', 'add', {
  158. homestayInfo: JSON.stringify(this.form)
  159. }, failres => {
  160. uni.showToast({
  161. icon: "none",
  162. title: failres.errmsg,
  163. duration: 3000
  164. });
  165. uni.hideLoading()
  166. }).then(res => {
  167. this.isSubmit = false
  168. uni.showToast({
  169. icon: "none",
  170. title: '提交成功,请等待平台审核',
  171. duration: 2000
  172. });
  173. uni.navigateBack()
  174. })
  175. },
  176. // 删除图片
  177. deletePic(event,status) {
  178. this[`fileList${event.name}`].splice(event.index, 1)
  179. },
  180. // 新增图片
  181. async afterRead(event,status) {
  182. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  183. let lists = [].concat(event.file)
  184. let fileListLen = this[`fileList${event.name}`].length
  185. lists.map((item) => {
  186. this[`fileList${event.name}`].push({
  187. ...item,
  188. status: 'uploading',
  189. message: '上传中'
  190. })
  191. })
  192. for (let i = 0; i < lists.length; i++) {
  193. const result = await this.uploadFilePromise(lists[i].url,status)
  194. let item = this[`fileList${event.name}`][fileListLen]
  195. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  196. status: 'success',
  197. message: '',
  198. url: result
  199. }))
  200. fileListLen++
  201. console.log(that.form, this[`fileList${event.name}`])
  202. }
  203. },
  204. uploadFilePromise(res,status) {
  205. return new Promise((resolve, reject) => {
  206. uploadImage(res, 'cardImages/',
  207. result => {
  208. if(status==1){
  209. that.form.personImageFront = result
  210. uni.showLoading({
  211. title: '加载中',
  212. mask: true
  213. })
  214. that.$request.baseRequest('admin.tourism.productManagement', 'personShibie', {
  215. personImageFront: that.form.personImageFront
  216. }, failres => {
  217. uni.showToast({
  218. icon: "none",
  219. title: failres.errmsg,
  220. duration: 3000
  221. });
  222. uni.hideLoading()
  223. }).then(res => {
  224. console.log(res)
  225. uni.hideLoading()
  226. that.form.personNo=res.data.recPersonNo
  227. console.log(that.form)
  228. that.$forceUpdate()
  229. })
  230. }else if(status==2){
  231. that.form.personImageBack = 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. // 人像
  260. .bgc,.bgc1{
  261. width:672rpx;
  262. height:417rpx;
  263. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card2.png') no-repeat center;
  264. background-size: 100%;
  265. text-align:center;
  266. }
  267. // 国徽
  268. .bgc1{
  269. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card.png') no-repeat center;
  270. background-size: 100%;
  271. }
  272. .path {
  273. color: #2772FB;
  274. }
  275. .icon_merchants_enterweigouxuan{
  276. color:#999;
  277. }
  278. .icon_merchants_entergouxuan{
  279. color:#5F7DE9;
  280. }
  281. </style>