createLifeService.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <view class='content'>
  3. <view class='wrap'>
  4. <u--form ref="uForm">
  5. <u-form-item labelPosition='left' label="主体">
  6. <u-radio-group activeColor="#f8bc31" placement='row' v-model="form.mainBody">
  7. <u-radio name="个人" >个人</u-radio>
  8. <u-radio name="商铺" >商铺</u-radio>
  9. </u-radio-group>
  10. </u-form-item>
  11. <u-form-item v-if='form.mainBody=="商铺"' labelWidth='80' labelPosition='left' label="店铺名称">
  12. <u-input maxlength="15" inputAlign='right' border='none' placeholder='输入店铺名称' v-model="form.shopNames" />
  13. </u-form-item>
  14. <u-form-item v-if='form.mainBody=="个人"' labelWidth='80' labelPosition='left' label="服务名称">
  15. <u-input maxlength="15" inputAlign='right' border='none' placeholder='输入服务名称,如跑腿、代驾' v-model="form.shopNames" />
  16. </u-form-item>
  17. <u-form-item labelWidth='80' labelPosition='top' label="封面图片">
  18. <u-upload :fileList="fileList1" @afterRead="afterRead($event,0)" @delete="deletePic" name="1" multiple
  19. :maxCount="1"></u-upload>
  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/find/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 maxlength="15" inputAlign='right' border='none' placeholder='输入详细地址,不超过15个字' v-model="form.detailedAddress" />
  31. </u-form-item>
  32. <u-form-item labelWidth='80' labelPosition='top' label="业务描述">
  33. <u--textarea v-model="form.serviceDescription" autoHeight placeholder="输入业务描述,0-200个字" ></u--textarea>
  34. </u-form-item>
  35. <view class='title'>以下信息为选填信息</view>
  36. <u-form-item v-if='form.mainBody=="商铺"' labelWidth='160' labelPosition='left' label="联系人(仅平台可见)">
  37. <u-input inputAlign='right' placeholder='输入联系人' border='none' v-model="form.realname" type="select" />
  38. </u-form-item>
  39. <u-form-item v-if='form.mainBody=="个人"' labelWidth='160' labelPosition='left' label="姓名(仅平台可见)">
  40. <u-input inputAlign='right' placeholder='输入姓名' border='none' v-model="form.realname" type="select" />
  41. </u-form-item>
  42. <u-form-item labelWidth='160' labelPosition='left' label="称呼(所有人可见)">
  43. <u-input inputAlign='right' placeholder='输入称呼,如李先生' border='none' v-model="form.sex" type="select" />
  44. </u-form-item>
  45. <u-form-item labelWidth='160' labelPosition='left' label="联系电话(所有人可见)">
  46. <u-input type='digit' inputAlign='right' maxlength="15" placeholder='输入联系电话' border='none' v-model="form.phone" />
  47. </u-form-item>
  48. <u-form-item v-if='form.mainBody=="商铺"' labelWidth='80' labelPosition='top' label="营业执照">
  49. <u-upload height='208' width='320' :fileList="fileList2" @afterRead="afterRead($event,1)" @delete="deletePic" name="2" multiple
  50. :maxCount="1">
  51. <image style='width:594rpx;height:378rpx;' src="../../static/image/find/yingyezhizhao.png" mode=""></image>
  52. </u-upload>
  53. </u-form-item>
  54. <view v-if='form.mainBody=="个人"' class='caution'>注:如提供风险类服务,请上传身份证信息</view>
  55. <u-form-item v-if='form.mainBody=="个人"' labelWidth='120' labelPosition='top' label="身份证头像面">
  56. <u-upload height='208' width='320' :fileList="fileList4" @afterRead="afterRead($event,2)" @delete="deletePic" name="4" multiple
  57. :maxCount="1">
  58. <view class="bgc">
  59. <image class='circle' style='width:123rpx;height:123rpx;' src="../../static/image/find/camera.png" mode=""></image>
  60. <view>请上传头像面</view>
  61. </view>
  62. </u-upload>
  63. </u-form-item>
  64. <u-form-item v-if='form.mainBody=="个人"' labelWidth='120' labelPosition='top' label="身份证国徽面">
  65. <u-upload height='208' width='320' :fileList="fileList6" @afterRead="afterRead($event,3)" @delete="deletePic" name="6" multiple
  66. :maxCount="1">
  67. <view class="bgc1">
  68. <image class='circle' style='width:123rpx;height:123rpx;' src="../../static/image/find/camera.png" mode=""></image>
  69. <view>请上传国徽面</view>
  70. </view>
  71. </u-upload>
  72. </u-form-item>
  73. <u-form-item v-if='form.mainBody=="个人"' labelWidth='120' labelPosition='left' label="身份证号码">
  74. <u-input inputAlign='right' border='none' placeholder='请输入身份证号码' v-model="form.personNo" />
  75. </u-form-item>
  76. <view></view>
  77. </u--form>
  78. <view class="footer">
  79. <button @click='submit' class="submit">提交</button>
  80. </view>
  81. </view>
  82. <!-- <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  83. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal> -->
  84. </view>
  85. </template>
  86. <script>
  87. var that
  88. import uploadImage from '@/components/ossutil/uploadFile.js';
  89. export default {
  90. data() {
  91. return {
  92. form:{
  93. mainBody:'商铺',
  94. city: '',
  95. area: '',
  96. province: '',
  97. location: '',
  98. detailedAddress: '',
  99. personImageFront:'',
  100. personImageBack:'',
  101. personNo:'',
  102. },
  103. content:'确定提交店铺信息',
  104. isSubmit:false,
  105. // 封面
  106. fileList:[],
  107. fileList1:[],
  108. // 营业执照
  109. fileList2:[],
  110. fileList3:[],
  111. // 头像面
  112. fileList4:[],
  113. fileList5:[],
  114. // 国徽面
  115. fileList6:[],
  116. fileList7:[],
  117. }
  118. },
  119. onLoad() {
  120. that = this
  121. },
  122. onShow() {
  123. },
  124. methods: {
  125. submit(){
  126. if(this.form.mainBody=='商铺'){
  127. this.content='确定提交店铺信息'
  128. }else{
  129. this.content='确定提交服务信息'
  130. }
  131. if(this.form.mainBody=='商铺'&&this.form.shopNames.length<2||this.form.mainBody=='商铺'&&this.form.shopNames.length>15){
  132. uni.showToast({
  133. icon: "none",
  134. title: '店铺名称2-15个字!',
  135. duration: 2000
  136. });
  137. return
  138. }
  139. if(this.form.mainBody=='个人'&&this.form.shopNames.length<2||this.form.mainBody=='个人'&&this.form.shopNames.length>15){
  140. uni.showToast({
  141. icon: "none",
  142. title: '服务名称2-15个字!',
  143. duration: 2000
  144. });
  145. return
  146. }
  147. if(!this.form.coverImage){
  148. uni.showToast({
  149. icon: "none",
  150. title: '封面图片不能为空!',
  151. duration: 2000
  152. });
  153. return
  154. }
  155. if(this.form.mainBody=='商铺'&!this.form.province){
  156. uni.showToast({
  157. icon: "none",
  158. title: '店铺位置不能为空!',
  159. duration: 2000
  160. });
  161. return
  162. }
  163. if(this.form.mainBody=='个人'&!this.form.province){
  164. uni.showToast({
  165. icon: "none",
  166. title: '定位不能为空!',
  167. duration: 2000
  168. });
  169. return
  170. }
  171. if(this.form.detailedAddress.length<6||this.form.detailedAddress.length>15){
  172. uni.showToast({
  173. icon: "none",
  174. title: '详细地址6-15个字!',
  175. duration: 2000
  176. });
  177. return
  178. }
  179. if(this.form.realname&&this.form.realname.length>6&&this.form.mainBody=='商铺'){
  180. uni.showToast({
  181. icon: "none",
  182. title: '联系人最多6个字!',
  183. duration: 2000
  184. });
  185. return
  186. }
  187. if(this.form.realname&&this.form.realname.length>6&&this.form.mainBody=='个人'){
  188. uni.showToast({
  189. icon: "none",
  190. title: '姓名最多6个字!',
  191. duration: 2000
  192. });
  193. return
  194. }
  195. uni.showModal({
  196. title: '提示',
  197. content: this.content,
  198. success (res) {
  199. if (res.confirm) {
  200. that.$u.debounce(that.confirmSubmit, 500)
  201. } else if (res.cancel) {
  202. console.log('用户点击取消')
  203. }
  204. }
  205. })
  206. // this.isSubmit = true
  207. },
  208. confirmSubmit() {
  209. uni.showLoading({
  210. title: '加载中',
  211. mask: true
  212. })
  213. this.$request.baseRequest('admin.tourism.productManagement', 'add', {
  214. productManagement: JSON.stringify(this.form)
  215. }, failres => {
  216. uni.showToast({
  217. icon: "none",
  218. title: failres.errmsg,
  219. duration: 3000
  220. });
  221. uni.hideLoading()
  222. }).then(res => {
  223. this.isSubmit = false
  224. uni.showToast({
  225. icon: "success",
  226. title: '提交成功!',
  227. duration: 2000
  228. });
  229. uni.navigateBack()
  230. })
  231. },
  232. placeSelect() {
  233. uni.chooseLocation({
  234. success: function(res) {
  235. console.log(res);
  236. that.form.location = res.latitude + ',' + res.longitude
  237. let _address = that.$helper.formatLocation(res.address)
  238. console.log(_address)
  239. that.form.province = _address.Province
  240. that.form.city = _address.City
  241. that.form.area = _address.Country
  242. that.form.detailedAddress = _address.Village
  243. that.$forceUpdate()
  244. }
  245. });
  246. },
  247. hideKeyboard() {
  248. uni.hideKeyboard()
  249. },
  250. // 删除图片
  251. deletePic(event,status) {
  252. this[`fileList${event.name}`].splice(event.index, 1)
  253. },
  254. // 新增图片
  255. async afterRead(event,status) {
  256. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  257. let lists = [].concat(event.file)
  258. let fileListLen = this[`fileList${event.name}`].length
  259. lists.map((item) => {
  260. this[`fileList${event.name}`].push({
  261. ...item,
  262. status: 'uploading',
  263. message: '上传中'
  264. })
  265. })
  266. for (let i = 0; i < lists.length; i++) {
  267. const result = await this.uploadFilePromise(lists[i].url,status)
  268. let item = this[`fileList${event.name}`][fileListLen]
  269. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  270. status: 'success',
  271. message: '',
  272. url: result
  273. }))
  274. fileListLen++
  275. console.log(that.form, this[`fileList${event.name}`])
  276. }
  277. },
  278. uploadFilePromise(res,status) {
  279. return new Promise((resolve, reject) => {
  280. uploadImage(res, 'cardImages/',
  281. result => {
  282. if(status==0){
  283. that.form.coverImage = result
  284. }else if(status==1){
  285. that.form.businessLicense = result
  286. }else if(status==2){
  287. that.form.personImageFront = result
  288. uni.showLoading({
  289. title: '加载中',
  290. mask: true
  291. })
  292. that.$request.baseRequest('admin.tourism.productManagement', 'personShibie', {
  293. personImageFront: that.form.personImageFront
  294. }, failres => {
  295. uni.showToast({
  296. icon: "none",
  297. title: failres.errmsg,
  298. duration: 3000
  299. });
  300. uni.hideLoading()
  301. }).then(res => {
  302. console.log(res)
  303. uni.hideLoading()
  304. that.form.personNo=res.data.recPersonNo
  305. console.log(that.form)
  306. that.$forceUpdate()
  307. })
  308. }else if(status==3){
  309. that.form.personImageBack = result
  310. }
  311. resolve(res)
  312. }
  313. )
  314. })
  315. },
  316. }
  317. }
  318. </script>
  319. <style lang="scss" scoped>
  320. .content{
  321. padding-bottom: 200rpx;
  322. }
  323. .wrap{
  324. padding:20rpx;
  325. }
  326. .title{
  327. font-size:36rpx;
  328. font-weight:600;
  329. margin:20rpx 0;
  330. }
  331. /deep/.u-radio-group,/deep/.u-radio-group--row {
  332. flex-direction: row-reverse !important;
  333. .u-radio{
  334. margin-left:10rpx;
  335. }
  336. }
  337. // 人像
  338. .bgc,.bgc1{
  339. width:672rpx;
  340. height:417rpx;
  341. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card2.png') no-repeat center;
  342. background-size: 100%;
  343. text-align:center;
  344. }
  345. // 国徽
  346. .bgc1{
  347. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card.png') no-repeat center;
  348. background-size: 100%;
  349. }
  350. .circle{
  351. margin:110rpx 0 20rpx 0;
  352. }
  353. /deep/.u-upload {
  354. .u-upload__deletable {
  355. height: 40rpx;
  356. width: 40rpx;
  357. line-height: 40rpx;
  358. }
  359. .u-upload__deletable__icon {
  360. top: 8rpx;
  361. }
  362. .uicon-close {
  363. font-size: 20px !important;
  364. }
  365. }
  366. </style>