createLifeService.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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' customStyle='align-items:center;' :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':diyAlignItems='"center"' :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' :diyAlignItems='"center"' :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. this.form.commonId = uni.getStorageSync("userInfo").id
  122. },
  123. onShow() {
  124. },
  125. methods: {
  126. submit(){
  127. if(this.form.mainBody=='商铺'){
  128. this.content='确定提交店铺信息?'
  129. }else{
  130. this.content='确定提交服务信息?'
  131. }
  132. if(this.form.mainBody=='商铺'&&this.form.shopNames.length<2||this.form.mainBody=='商铺'&&this.form.shopNames.length>15){
  133. uni.showToast({
  134. icon: "none",
  135. title: '店铺名称2-15个字!',
  136. duration: 2000
  137. });
  138. return
  139. }
  140. if(this.form.mainBody=='个人'&&this.form.shopNames.length<2||this.form.mainBody=='个人'&&this.form.shopNames.length>15){
  141. uni.showToast({
  142. icon: "none",
  143. title: '服务名称2-15个字!',
  144. duration: 2000
  145. });
  146. return
  147. }
  148. if(!this.form.coverImage){
  149. uni.showToast({
  150. icon: "none",
  151. title: '封面图片不能为空!',
  152. duration: 2000
  153. });
  154. return
  155. }
  156. if(this.form.mainBody=='商铺'&!this.form.province){
  157. uni.showToast({
  158. icon: "none",
  159. title: '店铺位置不能为空!',
  160. duration: 2000
  161. });
  162. return
  163. }
  164. if(this.form.mainBody=='个人'&!this.form.province){
  165. uni.showToast({
  166. icon: "none",
  167. title: '定位不能为空!',
  168. duration: 2000
  169. });
  170. return
  171. }
  172. if(this.form.detailedAddress.length<6||this.form.detailedAddress.length>15){
  173. uni.showToast({
  174. icon: "none",
  175. title: '详细地址6-15个字!',
  176. duration: 2000
  177. });
  178. return
  179. }
  180. if(this.form.realname&&this.form.realname.length>6&&this.form.mainBody=='商铺'){
  181. uni.showToast({
  182. icon: "none",
  183. title: '联系人最多6个字!',
  184. duration: 2000
  185. });
  186. return
  187. }
  188. if(this.form.realname&&this.form.realname.length>6&&this.form.mainBody=='个人'){
  189. uni.showToast({
  190. icon: "none",
  191. title: '姓名最多6个字!',
  192. duration: 2000
  193. });
  194. return
  195. }
  196. uni.showModal({
  197. title: '提示',
  198. content: this.content,
  199. success (res) {
  200. if (res.confirm) {
  201. that.$u.debounce(that.confirmSubmit, 500)
  202. } else if (res.cancel) {
  203. console.log('用户点击取消')
  204. }
  205. }
  206. })
  207. // this.isSubmit = true
  208. },
  209. confirmSubmit() {
  210. uni.showLoading({
  211. title: '加载中',
  212. mask: true
  213. })
  214. this.$request.baseRequest('admin.tourism.productManagement', 'add', {
  215. productManagement: JSON.stringify(this.form)
  216. }, failres => {
  217. uni.showToast({
  218. icon: "none",
  219. title: failres.errmsg,
  220. duration: 3000
  221. });
  222. uni.hideLoading()
  223. }).then(res => {
  224. this.isSubmit = false
  225. uni.showToast({
  226. icon: "success",
  227. title: '提交成功!',
  228. duration: 2000
  229. });
  230. uni.navigateBack()
  231. })
  232. },
  233. placeSelect() {
  234. uni.chooseLocation({
  235. success: function(res) {
  236. console.log(res);
  237. that.form.location = res.latitude + ',' + res.longitude
  238. let _address = that.$helper.formatLocation(res.address)
  239. console.log(_address)
  240. that.form.province = _address.Province
  241. that.form.city = _address.City
  242. that.form.area = _address.Country
  243. that.form.detailedAddress = _address.Village
  244. that.$forceUpdate()
  245. }
  246. });
  247. },
  248. hideKeyboard() {
  249. uni.hideKeyboard()
  250. },
  251. // 删除图片
  252. deletePic(event,status) {
  253. this[`fileList${event.name}`].splice(event.index, 1)
  254. },
  255. // 新增图片
  256. async afterRead(event,status) {
  257. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  258. let lists = [].concat(event.file)
  259. let fileListLen = this[`fileList${event.name}`].length
  260. lists.map((item) => {
  261. this[`fileList${event.name}`].push({
  262. ...item,
  263. status: 'uploading',
  264. message: '上传中'
  265. })
  266. })
  267. for (let i = 0; i < lists.length; i++) {
  268. const result = await this.uploadFilePromise(lists[i].url,status)
  269. let item = this[`fileList${event.name}`][fileListLen]
  270. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  271. status: 'success',
  272. message: '',
  273. url: result
  274. }))
  275. fileListLen++
  276. console.log(that.form, this[`fileList${event.name}`])
  277. }
  278. },
  279. uploadFilePromise(res,status) {
  280. return new Promise((resolve, reject) => {
  281. uploadImage(res, 'cardImages/',
  282. result => {
  283. if(status==0){
  284. that.form.coverImage = result
  285. }else if(status==1){
  286. that.form.businessLicense = result
  287. }else if(status==2){
  288. that.form.personImageFront = result
  289. uni.showLoading({
  290. title: '加载中',
  291. mask: true
  292. })
  293. that.$request.baseRequest('admin.tourism.productManagement', 'personShibie', {
  294. personImageFront: that.form.personImageFront
  295. }, failres => {
  296. uni.showToast({
  297. icon: "none",
  298. title: failres.errmsg,
  299. duration: 3000
  300. });
  301. uni.hideLoading()
  302. }).then(res => {
  303. console.log(res)
  304. uni.hideLoading()
  305. that.form.personNo=res.data.recPersonNo
  306. console.log(that.form)
  307. that.$forceUpdate()
  308. })
  309. }else if(status==3){
  310. that.form.personImageBack = result
  311. }
  312. resolve(res)
  313. }
  314. )
  315. })
  316. },
  317. }
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. .content{
  322. padding-bottom: 200rpx;
  323. }
  324. .wrap{
  325. padding:20rpx;
  326. }
  327. .title{
  328. font-size:36rpx;
  329. font-weight:600;
  330. margin:20rpx 0;
  331. }
  332. /deep/.u-radio-group,/deep/.u-radio-group--row {
  333. flex-direction: row-reverse !important;
  334. .u-radio{
  335. margin-left:10rpx;
  336. }
  337. }
  338. // 人像
  339. .bgc,.bgc1{
  340. width:672rpx;
  341. height:417rpx;
  342. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card2.png') no-repeat center;
  343. background-size: 100%;
  344. text-align:center;
  345. }
  346. // 国徽
  347. .bgc1{
  348. background:url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/card.png') no-repeat center;
  349. background-size: 100%;
  350. }
  351. .circle{
  352. margin:110rpx 0 20rpx 0;
  353. }
  354. /deep/.u-upload {
  355. .u-upload__deletable {
  356. height: 40rpx;
  357. width: 40rpx;
  358. line-height: 40rpx;
  359. }
  360. .u-upload__deletable__icon {
  361. top: 8rpx;
  362. }
  363. .uicon-close {
  364. font-size: 20px !important;
  365. }
  366. }
  367. /deep/view.align-item-center1{
  368. align-items: center !important;
  369. }
  370. </style>