edit.vue 12 KB

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