homestay.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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>
  53. <view class="footer">
  54. <button @click='submit' class="submit">提交</button>
  55. </view>
  56. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  57. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. var that
  63. import uploadImage from '@/components/ossutil/uploadFile.js';
  64. export default {
  65. data() {
  66. return {
  67. form:{
  68. },
  69. tips:'发送验证码',
  70. startDate:'',
  71. isSubmit:false,
  72. fileList4:[],
  73. fileList6:[],
  74. content:'确定提交店铺信息',
  75. }
  76. },
  77. onLoad() {
  78. that = this
  79. },
  80. onShow(){
  81. var date = new Date().toISOString().slice(0, 10)
  82. this.startDate=date
  83. },
  84. methods: {
  85. codeChange(text) {
  86. this.tips = text;
  87. },
  88. getCode() {
  89. if(!this.form.phone){
  90. uni.showToast({
  91. icon: "none",
  92. title: '请输入手机号再获取验证码!',
  93. duration: 2000
  94. });
  95. return
  96. }
  97. if (this.$refs.uCode.canGetCode) {
  98. // 模拟向后端请求验证码
  99. uni.showLoading({
  100. title: '正在获取验证码'
  101. })
  102. this.$request.baseRequest('user', 'sendVerifyCode', {
  103. phone: this.form.phone
  104. }, failres => {
  105. uni.showToast({
  106. icon: "none",
  107. title: failres.errmsg,
  108. duration: 3000
  109. });
  110. uni.hideLoading()
  111. }).then(res => {
  112. })
  113. setTimeout(() => {
  114. uni.hideLoading();
  115. // 这里此提示会被this.start()方法中的提示覆盖
  116. // 通知验证码组件内部开始倒计时
  117. this.$refs.uCode.start();
  118. }, 2000);
  119. } else {
  120. uni.showToast({
  121. icon: "success",
  122. title: '提交成功!',
  123. duration: 2000
  124. });
  125. }
  126. },
  127. submit(){
  128. this.isSubmit = true
  129. },
  130. confirmSubmit(){
  131. uni.showLoading({
  132. title: '加载中',
  133. mask: true
  134. })
  135. this.$request.baseRequest('admin.tourism.homestayInfo', 'add', {
  136. homestayInfo: JSON.stringify(this.form)
  137. }, failres => {
  138. uni.showToast({
  139. icon: "none",
  140. title: failres.errmsg,
  141. duration: 3000
  142. });
  143. uni.hideLoading()
  144. }).then(res => {
  145. this.isSubmit = false
  146. uni.showToast({
  147. icon: "success",
  148. title: '提交成功!',
  149. duration: 2000
  150. });
  151. uni.navigateBack()
  152. })
  153. },
  154. // 删除图片
  155. deletePic(event,status) {
  156. this[`fileList${event.name}`].splice(event.index, 1)
  157. },
  158. // 新增图片
  159. async afterRead(event,status) {
  160. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  161. let lists = [].concat(event.file)
  162. let fileListLen = this[`fileList${event.name}`].length
  163. lists.map((item) => {
  164. this[`fileList${event.name}`].push({
  165. ...item,
  166. status: 'uploading',
  167. message: '上传中'
  168. })
  169. })
  170. for (let i = 0; i < lists.length; i++) {
  171. const result = await this.uploadFilePromise(lists[i].url,status)
  172. let item = this[`fileList${event.name}`][fileListLen]
  173. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  174. status: 'success',
  175. message: '',
  176. url: result
  177. }))
  178. fileListLen++
  179. console.log(that.form, this[`fileList${event.name}`])
  180. }
  181. },
  182. uploadFilePromise(res,status) {
  183. return new Promise((resolve, reject) => {
  184. uploadImage(res, 'cardImages/',
  185. result => {
  186. if(status==1){
  187. that.form.personImageFront = result
  188. uni.showLoading({
  189. title: '加载中',
  190. mask: true
  191. })
  192. that.$request.baseRequest('admin.tourism.productManagement', 'personShibie', {
  193. personImageFront: that.form.personImageFront
  194. }, failres => {
  195. uni.showToast({
  196. icon: "none",
  197. title: failres.errmsg,
  198. duration: 3000
  199. });
  200. uni.hideLoading()
  201. }).then(res => {
  202. console.log(res)
  203. uni.hideLoading()
  204. that.form.personNo=res.data.recPersonNo
  205. console.log(that.form)
  206. that.$forceUpdate()
  207. })
  208. }else if(status==2){
  209. that.form.personImageBack = result
  210. }
  211. resolve(res)
  212. }
  213. )
  214. })
  215. },
  216. }
  217. }
  218. </script>
  219. <style lang='scss' scoped>
  220. .wrap{
  221. padding:20rpx;
  222. }
  223. .icon_merchants_enterjian1{
  224. margin-left:10rpx;
  225. font-size:50rpx;
  226. }
  227. .add_label,.get_code{
  228. background: #5F7DE9;
  229. color: #fff;
  230. padding: 10rpx 20rpx;
  231. border-radius: 10rpx;
  232. font-size: 26rpx;
  233. }
  234. .circle{
  235. margin:110rpx 0 20rpx 0;
  236. }
  237. // 人像
  238. .bgc,.bgc1{
  239. width:672rpx;
  240. height:417rpx;
  241. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card2.png') no-repeat center;
  242. background-size: 100%;
  243. text-align:center;
  244. }
  245. // 国徽
  246. .bgc1{
  247. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card.png') no-repeat center;
  248. background-size: 100%;
  249. }
  250. </style>