homestay.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. userInfo:{},
  87. content:'确定提交入驻信息',
  88. }
  89. },
  90. onLoad() {
  91. that = this
  92. },
  93. onShow(){
  94. var date = new Date().toISOString().slice(0, 10)
  95. this.startDate=date
  96. },
  97. methods: {
  98. codeChange(text) {
  99. this.tips = text;
  100. },
  101. getCode() {
  102. if(!this.form.phone){
  103. uni.showToast({
  104. icon: "none",
  105. title: '请输入手机号再获取验证码!',
  106. duration: 2000
  107. });
  108. return
  109. }
  110. if (this.$refs.uCode.canGetCode) {
  111. // 模拟向后端请求验证码
  112. uni.showLoading({
  113. title: '正在获取验证码'
  114. })
  115. this.$request.baseRequest('user', 'sendVerifyCode', {
  116. phone: this.form.phone
  117. }, failres => {
  118. uni.showToast({
  119. icon: "none",
  120. title: failres.errmsg,
  121. duration: 3000
  122. });
  123. uni.hideLoading()
  124. }).then(res => {
  125. })
  126. setTimeout(() => {
  127. uni.hideLoading();
  128. // 这里此提示会被this.start()方法中的提示覆盖
  129. // 通知验证码组件内部开始倒计时
  130. this.$refs.uCode.start();
  131. }, 2000);
  132. } else {
  133. uni.showToast({
  134. icon: "success",
  135. title: '提交成功!',
  136. duration: 2000
  137. });
  138. }
  139. },
  140. submit(){
  141. uni.showModal({
  142. title: '提示',
  143. content: '确定提交入驻信息?',
  144. success (res) {
  145. if (res.confirm) {
  146. that.$u.debounce(confirmSubmit, 500)
  147. } else if (res.cancel) {
  148. console.log('用户点击取消')
  149. }
  150. }
  151. })
  152. },
  153. confirmSubmit(){
  154. uni.showLoading({
  155. title: '加载中',
  156. mask: true
  157. })
  158. this.$request.baseRequest('admin.tourism.homestayInfo', 'add', {
  159. homestayInfo: JSON.stringify(this.form)
  160. }, failres => {
  161. uni.showToast({
  162. icon: "none",
  163. title: failres.errmsg,
  164. duration: 3000
  165. });
  166. uni.hideLoading()
  167. }).then(res => {
  168. this.isSubmit = false
  169. uni.showToast({
  170. icon: "none",
  171. title: '提交成功,请等待平台审核',
  172. duration: 2000
  173. });
  174. this.userInfo=uni.getStorageSync("userInfo")
  175. this.userInfo.homeEntry+=1
  176. uni.setStorageSync("userInfo",this.userInfo)
  177. uni.navigateBack()
  178. })
  179. },
  180. // 删除图片
  181. deletePic(event,status) {
  182. this[`fileList${event.name}`].splice(event.index, 1)
  183. },
  184. // 新增图片
  185. async afterRead(event,status) {
  186. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  187. let lists = [].concat(event.file)
  188. let fileListLen = this[`fileList${event.name}`].length
  189. lists.map((item) => {
  190. this[`fileList${event.name}`].push({
  191. ...item,
  192. status: 'uploading',
  193. message: '上传中'
  194. })
  195. })
  196. for (let i = 0; i < lists.length; i++) {
  197. const result = await this.uploadFilePromise(lists[i].url,status)
  198. let item = this[`fileList${event.name}`][fileListLen]
  199. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  200. status: 'success',
  201. message: '',
  202. url: result
  203. }))
  204. fileListLen++
  205. console.log(that.form, this[`fileList${event.name}`])
  206. }
  207. },
  208. uploadFilePromise(res,status) {
  209. return new Promise((resolve, reject) => {
  210. uploadImage(res, 'cardImages/',
  211. result => {
  212. if(status==1){
  213. that.form.personImageFront = result
  214. uni.showLoading({
  215. title: '加载中',
  216. mask: true
  217. })
  218. that.$request.baseRequest('admin.tourism.productManagement', 'personShibie', {
  219. personImageFront: that.form.personImageFront
  220. }, failres => {
  221. uni.showToast({
  222. icon: "none",
  223. title: failres.errmsg,
  224. duration: 3000
  225. });
  226. uni.hideLoading()
  227. }).then(res => {
  228. console.log(res)
  229. uni.hideLoading()
  230. that.form.personNo=res.data.recPersonNo
  231. console.log(that.form)
  232. that.$forceUpdate()
  233. })
  234. }else if(status==2){
  235. that.form.personImageBack = 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. // 人像
  264. .bgc,.bgc1{
  265. width:672rpx;
  266. height:417rpx;
  267. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card2.png') no-repeat center;
  268. background-size: 100%;
  269. text-align:center;
  270. }
  271. // 国徽
  272. .bgc1{
  273. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card.png') no-repeat center;
  274. background-size: 100%;
  275. }
  276. .path {
  277. color: #2772FB;
  278. }
  279. .icon_merchants_enterweigouxuan{
  280. color:#999;
  281. }
  282. .icon_merchants_entergouxuan{
  283. color:#5F7DE9;
  284. }
  285. </style>