createLifeService.vue 12 KB

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