edit.vue 13 KB

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