activityEdit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <template>
  2. <view>
  3. <view v-if="stepOne">
  4. <view class="form">
  5. <view class="form-title">基本信息</view>
  6. <view class="form-item-title">封面图</view>
  7. <view class="upload-pic ddflex" v-if="!pic" @click="uploadImage(1)">
  8. <image src="../static/images/pic.png"></image>
  9. <view style="margin-top: 30rpx;">上传封面图</view>
  10. </view>
  11. <image v-else class="upload-image" :src="pic" @click="uploadImage(1)"></image>
  12. <view class="form-limit">* 图片尺寸限制:680*350</view>
  13. <block v-if="type==1">
  14. <view class="form-item-title">活动详情轮播图</view>
  15. <view class="ddflex" style="margin-top: 30rpx;">
  16. <view class="upload-photo-image" v-for="item ,index in fileList" @click="uploadImage(2,index+1)">
  17. <image :src="item" mode="aspectFill"></image>
  18. <image class="upload-photo-close" src="/static/pages/images/close3.png"
  19. @click.stop="deleteImage(2,index+1)"></image>
  20. </view>
  21. <view class="upload-photo ddflex" @click="uploadImage(2)" v-if="fileList.length<9">
  22. <image src="../static/images/photo.png"></image>
  23. </view>
  24. </view>
  25. <view class="form-limit">* 图片尺寸限制:670*350</view>
  26. </block>
  27. </view>
  28. <view class="form-border"></view>
  29. <view class="form">
  30. <view class="form-item-title">活动标题</view>
  31. <view class="form-input-box">
  32. <input v-model="title" placeholder-class="form-input-placeholder" placeholder="请输入活动标题" />
  33. </view>
  34. <view class="form-item-title">活动类型</view>
  35. <view class="form-input-box ddflex">
  36. <view class="ddflex" @click="changeType(1)">
  37. <image v-if="type!=1" style="width: 28rpx;height: 28rpx;margin-right: 10rpx;" src="/static/images/select.png"></image>
  38. <image v-else style="width: 28rpx;height: 28rpx;margin-right: 10rpx;" src="/static/images/select_h.png"></image>
  39. <view>普通活动</view>
  40. </view>
  41. <view class="ddflex" style="margin-left:30rpx" @click="changeType(2)">
  42. <image v-if="type!=2" style="width: 28rpx;height: 28rpx;margin-right: 10rpx;" src="/static/images/select.png"></image>
  43. <image v-else style="width: 28rpx;height: 28rpx;margin-right: 10rpx;" src="/static/images/select_h.png"></image>
  44. <view>外链活动</view>
  45. </view>
  46. </view>
  47. <block v-if="type==2">
  48. <view class="form-item-title">活动链接</view>
  49. <view class="form-input-box">
  50. <input v-model="link" placeholder-class="form-input-placeholder" placeholder="请填写活动链接" />
  51. </view>
  52. </block>
  53. <block v-if="type==1">
  54. <view class="form-item-title">活动说明</view>
  55. <view class="form-input-box">
  56. <input v-model="brief" placeholder-class="form-input-placeholder" placeholder="请填写活动简介说明" />
  57. </view>
  58. <view class="form-item-title">
  59. 活动详情
  60. <view class="more ddflex" @click="jumpUrl('/match/editorContent/editorContent')">
  61. <text v-if="!text">编辑</text>
  62. <text v-else style="color: var(--main);">已完善</text>
  63. <image src="../../static/pages/images/more.png"></image>
  64. </view>
  65. </view>
  66. <view class="form-input-box" style="padding: 18rpx 0;">
  67. </view>
  68. <view class="form-item-title">
  69. 自定义报名信息
  70. <view class="more ddflex" @click="jumpUrl('/match/addForm/addForm')">
  71. <text style="color: #999;" v-if="!extForm">添加(非必填)</text>
  72. <text v-else style="color: var(--main);">已添加</text>
  73. <image src="../../static/pages/images/more.png"></image>
  74. </view>
  75. </view>
  76. <view class="form-input-box" style="padding: 18rpx 0;">
  77. </view>
  78. <view class="form-item-title">
  79. 活动分类
  80. <view class="more ddflex" @click="jumpUrl('/match/sort/sort')">
  81. <text style="color: #999;" v-if="!matchType">添加(非必填)</text>
  82. <text v-else style="color: var(--main);">已添加</text>
  83. <image src="../../static/pages/images/more.png"></image>
  84. </view>
  85. </view>
  86. </block>
  87. <block v-if="type==2">
  88. <view class="form-item-title ddflex" style="justify-content: space-between;">
  89. 是否全省通用
  90. <switch v-model="isAllSee" :checked="isAllSee" style="transform:scale(0.7)" color="var(--main)"
  91. @change="powerChange"></switch>
  92. </view>
  93. <block v-if="!isAllSee">
  94. <view class="form-input-box" style="border-bottom: none;" @click="showPop()">
  95. 已选择{{checkNum}}个区域
  96. <view class="more ddflex">
  97. <!-- <text v-if="!text">编辑</text>
  98. <text v-else style="color: var(--main);">已完善</text> -->
  99. <image src="../../static/pages/images/more.png"></image>
  100. </view>
  101. </view>
  102. <view class="form-item-title" style="color: red;font-size: 24rpx;margin-top: 0rpx;" v-if="checkNum==0">
  103. *请选择活动生效区域
  104. </view>
  105. <view class="mask" v-if="isShowPop" @click="hidePop"></view>
  106. <view class="popup" v-if="isShowPop">
  107. <view class="popupc ddflex">
  108. <view class="pleft">
  109. <view :class="'li ddflex' + (checkIndex == index ? ' active':'')" style="justify-content: space-between;"
  110. v-for="(item,index) in industryList" :key="index" @click="checkIndustry(index)">
  111. <view class="fflex tover">{{item.label}}</view>
  112. <image v-if="item.isActive" style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox_h.png" @click.stop="checkBoxIndustry(index)"></image>
  113. <image v-else style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox.png" @click.stop="checkBoxIndustry(index)"></image>
  114. </view>
  115. </view>
  116. <view class="pright">
  117. <view :class="'li ddflex' + (arrayIndex == index ? ' active':'')" style="justify-content: space-between;"
  118. v-for="(item,index) in rightArray" :key="index" @click="checkArray(index)">
  119. <view class="fflex tover">{{item.label}}</view>
  120. <image v-if="item.isActive" style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox_h.png" @click.stop="checkBoxArray(index)"></image>
  121. <image v-else style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox.png" @click.stop="checkBoxArray(index)"></image>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </block>
  127. </block>
  128. <view class="next-btn" v-if="type==1" @click="next">下一步</view>
  129. <view class="next-btn" v-if="type==2" @click="submit()">提交</view>
  130. </view>
  131. </view>
  132. <!-- 第二步 -->
  133. <view v-if="stepTwo">
  134. <view class="form">
  135. <view class="form-title">报名设置</view>
  136. <view class="form-item-title">活动最大报名人数</view>
  137. <view class="form-number-select ddflex">
  138. <view @click="jian">-</view>
  139. <input v-model="personLimit" type="number" placeholder="最大报名人数"
  140. placeholder-class="form-input-placeholder" />
  141. <view @click="jia">+</view>
  142. </view>
  143. <view class="form-item-title" style="color: red;font-size: 24rpx;margin-top: 20rpx;" v-if="checkNum==0">
  144. *-1为不限制报名人数
  145. </view>
  146. <view class="form-item-title">单次最大报名人数</view>
  147. <view class="form-number-select ddflex">
  148. <view @click="jianEnlistPerson">-</view>
  149. <input v-model="enlistPersonLimit" type="number" placeholder="单次最大报名人数"
  150. placeholder-class="form-input-placeholder" />
  151. <view @click="jiaEnlistPerson">+</view>
  152. </view>
  153. <view class="form-item-title" style="color: red;font-size: 24rpx;margin-top: 20rpx;" v-if="checkNum==0">
  154. *-1为不限制单次最大报名人数
  155. </view>
  156. <view class="form-item-title">报名时间</view>
  157. <view class="ddflex" style="margin-top: 20rpx;">
  158. <picker v-model="enlistStartTime" mode="date" class="flex" @change="enlistStartTimeChange">
  159. <view class="form-date-select" :style="enlistStartTime?'color:#333':''">
  160. {{enlistStartTime?enlistStartTime:'开始日期'}}
  161. </view>
  162. </picker>
  163. <text style="margin: 0 20rpx;">至</text>
  164. <picker v-model="enlistEndTime" mode="date" class="flex" @change="enlistEndTimeChange">
  165. <view class="form-date-select" :style="enlistEndTime?'color:#333':''">
  166. {{enlistEndTime?enlistEndTime:'结束日期'}}
  167. </view>
  168. </picker>
  169. </view>
  170. <view class="form-item-title">活动时间</view>
  171. <view class="ddflex" style="margin-top: 20rpx;">
  172. <picker v-model="startTime" mode="date" class="flex" @change="startTimeChange">
  173. <view class="form-date-select" :style="startTime?'color:#333':''">
  174. {{startTime?startTime:"开始日期"}}
  175. </view>
  176. </picker>
  177. <text style="margin: 0 20rpx;">至</text>
  178. <picker v-model="endTime" mode="date" class="flex" @change="endTimeChange">
  179. <view class="form-date-select" :style="endTime?'color:#333':''">
  180. {{endTime?endTime:"结束日期"}}
  181. </view>
  182. </picker>
  183. </view>
  184. </view>
  185. <view class="form-border"></view>
  186. <view class="form">
  187. <view class="form-title">活动地址</view>
  188. <view class="form-item-title">地址名称</view>
  189. <view class="form-input-box">
  190. <input v-model="house" placeholder-class="form-input-placeholder" placeholder="请输入活动地址简称" />
  191. </view>
  192. <view class="form-item-title">选择城市</view>
  193. <view class="form-input-box">
  194. <!-- <picker class="form-input-placeholder" mode="region" @change="bindRegionChange" :value="region" > -->
  195. <view class="picker" :style="region.length>0?'color: #333;':'color:#cccccc'"
  196. @click="chooseLocation()">
  197. {{region.length > 0 ? region[0]+region[1]+region[2] : '请选择所在城市'}}
  198. </view>
  199. <!-- </picker> -->
  200. <!-- <image src="/card/static/images/area.png" class="loca" @click="chooseLocation()"></image> -->
  201. </view>
  202. <view class="form-item-title">
  203. 详细地址
  204. </view>
  205. <view class="form-input-box">
  206. <input v-model="address" placeholder-class="form-input-placeholder" placeholder="请输入详细地址" />
  207. </view>
  208. <view class="form-item-title ddflex" style="justify-content: space-between;">
  209. 是否全省通用
  210. <switch v-model="isAllSee" :checked="isAllSee" style="transform:scale(0.7)" color="var(--main)"
  211. @change="powerChange"></switch>
  212. </view>
  213. <block v-if="!isAllSee">
  214. <view class="form-input-box" style="border-bottom: none;" @click="showPop()">
  215. 已选择{{checkNum}}个区域
  216. <view class="more ddflex">
  217. <!-- <text v-if="!text">编辑</text>
  218. <text v-else style="color: var(--main);">已完善</text> -->
  219. <image src="../../static/pages/images/more.png"></image>
  220. </view>
  221. </view>
  222. <view class="form-item-title" style="color: red;font-size: 24rpx;margin-top: 0rpx;" v-if="checkNum==0">
  223. *请选择活动生效区域
  224. </view>
  225. <view class="mask" v-if="isShowPop" @click="hidePop"></view>
  226. <view class="popup" v-if="isShowPop">
  227. <view class="popupc ddflex">
  228. <view class="pleft">
  229. <view :class="'li ddflex' + (checkIndex == index ? ' active':'')" style="justify-content: space-between;"
  230. v-for="(item,index) in industryList" :key="index" @click="checkIndustry(index)">
  231. <view class="fflex tover">{{item.label}}</view>
  232. <image v-if="item.isActive" style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox_h.png" @click.stop="checkBoxIndustry(index)"></image>
  233. <image v-else style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox.png" @click.stop="checkBoxIndustry(index)"></image>
  234. </view>
  235. </view>
  236. <view class="pright">
  237. <view :class="'li ddflex' + (arrayIndex == index ? ' active':'')" style="justify-content: space-between;"
  238. v-for="(item,index) in rightArray" :key="index" @click="checkArray(index)">
  239. <view class="fflex tover">{{item.label}}</view>
  240. <image v-if="item.isActive" style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox_h.png" @click.stop="checkBoxArray(index)"></image>
  241. <image v-else style="width: 25rpx;height: 25rpx;margin-left: 10rpx;" src="/match/static/images/checkBox.png" @click.stop="checkBoxArray(index)"></image>
  242. </view>
  243. </view>
  244. </view>
  245. </view>
  246. </block>
  247. <view class="next-btn" @click="submit()">提交</view>
  248. </view>
  249. </view>
  250. </view>
  251. </template>
  252. <script>
  253. import util from "../../utils/util.js";
  254. const app = getApp();
  255. const req = require("../../utils/request.js");
  256. export default {
  257. components: {},
  258. props: {},
  259. data() {
  260. return {
  261. stepOne: true,
  262. stepTwo: false,
  263. pic: '', //封面图
  264. fileList: [], //banner
  265. title: '',
  266. brief: '',
  267. text: '',
  268. type:1,//1普通活动 2外链活动
  269. link:'',
  270. matchType:'',//活动分类
  271. personLimit: -1,
  272. enlistPersonLimit:-1,
  273. enlistStartTime: '',
  274. enlistEndTime: '',
  275. startTime: '',
  276. endTime: '',
  277. house: '',
  278. region: [],
  279. address: '',
  280. regionCode: [],
  281. id: '',
  282. longitude: null,
  283. latitude: null,
  284. isAllSee: true,
  285. isShowPop: false,
  286. checkIndex: 0,
  287. industryList: [],
  288. arrayIndex: -1,
  289. rightArray: [],
  290. companyTreeList:[],
  291. checkNum:0,
  292. extForm:''
  293. }
  294. },
  295. async onLoad(options) {
  296. this.id = options.id
  297. await this.getCompanyTreeList()
  298. if (this.id) {
  299. this.getActivityInfo()
  300. }
  301. },
  302. onShow() {
  303. },
  304. methods: {
  305. jumpUrl(url) {
  306. uni.navigateTo({
  307. url: url
  308. })
  309. },
  310. // 获取公司代码
  311. getCompanyTreeList(){
  312. return new Promise((r,j)=>{
  313. req.getRequest('/api/company/treeList',{},res=>{
  314. this.companyTreeList = res
  315. this.industryList = this.companyTreeList[0]&&this.companyTreeList[0].children?this.companyTreeList[0].children:[]
  316. this.rightArray = this.industryList[0]&&this.industryList[0].children?this.industryList[0].children:[]
  317. r()
  318. })
  319. })
  320. },
  321. checkIndustry(index){
  322. if(this.checkIndex == index) return false;
  323. this.checkIndex = index;
  324. this.rightArray = this.industryList[this.checkIndex].children;
  325. },
  326. checkBoxIndustry(index){
  327. if(this.industryList[index].isActive){
  328. this.industryList[index].isActive = false
  329. this.industryList[index].children.map(item=>{item.isActive = false})
  330. }else{
  331. this.industryList[index].isActive = true
  332. this.industryList[index].children.map(item=>{item.isActive = true})
  333. }
  334. this.industryList = JSON.parse(JSON.stringify(this.industryList))
  335. this.checkIndex = index;
  336. this.rightArray = this.industryList[this.checkIndex].children;
  337. },
  338. checkBoxArray(index){
  339. if(this.industryList[this.checkIndex].children[index].isActive){
  340. this.industryList[this.checkIndex].children[index].isActive = false
  341. }else{
  342. this.industryList[this.checkIndex].children[index].isActive = true
  343. }
  344. console.log(this.industryList[this.checkIndex].children.some(item=>item.isActive == false))
  345. if(this.industryList[this.checkIndex].children.some(item=>item.isActive == true)){
  346. this.industryList[this.checkIndex].isActive = true
  347. }else{
  348. this.industryList[this.checkIndex].isActive = false
  349. }
  350. this.industryList = JSON.parse(JSON.stringify(this.industryList))
  351. this.rightArray = this.industryList[this.checkIndex].children;
  352. },
  353. getCheckNum(){
  354. console.log(this.checkNum)
  355. this.checkNum = 0
  356. if(!this.isAllSee){
  357. this.industryList.map(item=>{
  358. item.children.map(it=>{
  359. if(it.isActive){
  360. this.checkNum++
  361. }
  362. })
  363. })
  364. }
  365. },
  366. getActivityInfo() {
  367. req.getRequest('/api/match/detail', {
  368. id: this.id
  369. }, res => {
  370. this.pic = res.pic
  371. this.fileList = res.imageList.map(item => {
  372. return item.url
  373. })
  374. this.title = res.title
  375. this.brief = res.brief
  376. this.text = res.text
  377. this.type = res.type?res.type:1
  378. if(this.type==2){
  379. this.link = res.text
  380. }else{
  381. this.link = ''
  382. }
  383. this.matchType = res.matchType?res.matchType:''
  384. this.personLimit = res.personLimit
  385. this.enlistPersonLimit = res.enlistPersonLimit&&res.enlistPersonLimit>0?res.enlistPersonLimit:-1
  386. this.extForm = res.extForm
  387. this.enlistStartTime = res.enlistStartTime?this.formatTime(res.enlistStartTime):''
  388. this.enlistEndTime = res.enlistEndTime?this.formatTime(res.enlistEndTime):''
  389. this.startTime = res.startTime?this.formatTime(res.startTime):''
  390. this.endTime = res.endTime?this.formatTime(res.endTime):''
  391. this.house = res.house?res.house:''
  392. if(res.province&&res.city&&res.country){
  393. this.regionCode = [res.province, res.city, res.country]
  394. }
  395. this.region = res.areaAdd?res.areaAdd.split(','):[]
  396. this.address = res.address?res.address:''
  397. this.longitude = res.lng ? res.lng : null
  398. this.latitude = res.lat ? res.lat : null
  399. if(res.areaCodeList.length>0){
  400. this.isAllSee = false
  401. let areaCodeList = res.areaCodeList.map(item=>item.areaCode)
  402. this.industryList.map(item=>{
  403. item.children.map(it=>{
  404. if(areaCodeList.indexOf(it.value)>-1){
  405. it.isActive = true
  406. }else{
  407. it.isActive = false
  408. }
  409. })
  410. if(item.children.some(it=>it.isActive == true)){
  411. item.isActive = true
  412. }else{
  413. item.isActive = false
  414. }
  415. })
  416. this.getCheckNum()
  417. }else{
  418. this.isAllSee = true
  419. }
  420. })
  421. },
  422. next() {
  423. if (!this.pic) {
  424. return req.msg('请上传封面图')
  425. }
  426. if (this.type==1 && this.fileList.length == 0) {
  427. return req.msg('请上传活动轮播图')
  428. }
  429. if (!this.title) {
  430. return req.msg('请填写活动名称')
  431. }
  432. if (this.type==1 && !this.brief) {
  433. return req.msg('请填写活动简介')
  434. }
  435. if (this.type==1 && !this.text) {
  436. return req.msg('请填写活动详情')
  437. }
  438. this.stepOne = false
  439. this.stepTwo = true
  440. },
  441. uploadImage(type, index) {
  442. let that = this;
  443. let count = 1
  444. if (type == 1) {
  445. count = 1
  446. } else if (type == 2) {
  447. if (index) {
  448. count = 1
  449. } else {
  450. count = 9 - that.fileList.length
  451. }
  452. }
  453. uni.chooseImage({
  454. count: count,
  455. sizeType: ['original', 'compressed'],
  456. sourceType: ['album', 'camera'],
  457. success: function({
  458. tempFilePaths
  459. }) {
  460. uni.showLoading({
  461. title:'上传中'
  462. })
  463. var promise = Promise.all(
  464. tempFilePaths.map(tempFilePath => {
  465. return new Promise(function(resolve, reject) {
  466. req.uploadFile('/api/nocheck/upload', tempFilePath,
  467. res => {
  468. // type 1 封面图
  469. if (type == 1) {
  470. that.pic = res.src
  471. } else if (type == 2) {
  472. if (index) {
  473. that.fileList[index] = res.src
  474. that.fileList = JSON.parse(JSON
  475. .stringify(that.fileList))
  476. } else {
  477. that.fileList = that.fileList.concat(
  478. res.src)
  479. }
  480. }
  481. resolve()
  482. });
  483. });
  484. })
  485. );
  486. promise
  487. .then(function(results) {
  488. uni.hideLoading()
  489. console.log(results);
  490. })
  491. .catch(function(err) {
  492. uni.hideLoading()
  493. console.log(err);
  494. });
  495. }
  496. });
  497. },
  498. deleteImage(type, index) {
  499. if (type == 2)
  500. this.fileList.splice(index, 1)
  501. },
  502. enlistStartTimeChange(e) {
  503. if (this.enlistEndTime) {
  504. if (this.enlistEndTime < e.detail.value)
  505. return req.msg('报名开始时间不能大于结束时间')
  506. }
  507. this.enlistStartTime = e.detail.value
  508. },
  509. enlistEndTimeChange(e) {
  510. if (this.enlistStartTime) {
  511. if (this.enlistStartTime > e.detail.value)
  512. return req.msg('报名结束时间不能小于开始时间')
  513. }
  514. this.enlistEndTime = e.detail.value
  515. },
  516. startTimeChange(e) {
  517. if (this.endTime) {
  518. if (this.endTime < e.detail.value)
  519. return req.msg('活动开始时间不能大于结束时间')
  520. }
  521. this.startTime = e.detail.value
  522. },
  523. endTimeChange(e) {
  524. if (this.startTime) {
  525. if (this.startTime > e.detail.value)
  526. return req.msg('活动结束时间不能小于开始时间')
  527. }
  528. this.endTime = e.detail.value
  529. },
  530. chooseLocation() {
  531. var tha = this;
  532. uni.chooseLocation({
  533. success: function(res) {
  534. if (res.name) {
  535. tha.address = res.name;
  536. tha.reverseGeocoder(res);
  537. console.log('地址数据》》》:', res);
  538. }
  539. }
  540. });
  541. },
  542. reverseGeocoder(location) {
  543. // #ifdef H5
  544. location = location.latitude + ',' + location.longitude
  545. let url = 'https://apis.map.qq.com/ws/geocoder/v1/?address=';
  546. this.$jsonp(url, {
  547. key: req.public.mapLBSKEY,
  548. location: location,
  549. output: 'jsonp'
  550. }).then(data => {
  551. console.log('解析后的地址地址数据:', data);
  552. data = data.result
  553. this.region = [data.ad_info.province, data.ad_info.city, data.ad_info.district]
  554. this.regionCode = [data.ad_info.adcode.substring(0, 2) + '0000', data.ad_info.adcode.substring(
  555. 0, 4) + '00', data.ad_info.adcode]
  556. this.longitude = data.ad_info.location.lng
  557. this.latitude = data.ad_info.location.lat
  558. }).catch(err => {
  559. console.log(err);
  560. });
  561. // #endif
  562. // #ifndef H5
  563. QQMapWX.initMap();
  564. QQMapWX.reverseGeocoder(location, data => {
  565. console.log('解析后的地址地址数据:', data);
  566. this.region = [data.ad_info.province, data.ad_info.city, data.ad_info.district]
  567. this.regionCode = [data.ad_info.adcode.substring(0, 2) + '0000', data.ad_info.adcode.substring(
  568. 0, 4) + '00', data.ad_info.adcode]
  569. this.longitude = data.ad_info.location.lng
  570. this.latitude = data.ad_info.location.lat
  571. });
  572. //#endif
  573. },
  574. bindRegionChange(event) {
  575. console.log(event)
  576. this.region = event.detail.value
  577. this.regionCode = event.detail.code
  578. },
  579. powerChange(e) {
  580. this.isAllSee = e.detail.value
  581. },
  582. showPop(){
  583. this.isShowPop = true;
  584. },
  585. hidePop(){
  586. this.isShowPop = false;
  587. this.getCheckNum()
  588. },
  589. submit() {
  590. if (!this.pic) {
  591. return req.msg('请上传封面图')
  592. }
  593. if (this.type==1 && this.fileList.length == 0) {
  594. return req.msg('请上传活动轮播图')
  595. }
  596. if (!this.title) {
  597. return req.msg('请填写活动名称')
  598. }
  599. if (this.type==2 && !this.link) {
  600. return req.msg('请填写活动链接')
  601. }
  602. if (this.type==1 && !this.brief) {
  603. return req.msg('请填写活动简介')
  604. }
  605. if (this.type==1 && !this.text) {
  606. return req.msg('请填写活动详情')
  607. }
  608. if (this.type==1 && !this.enlistStartTime) {
  609. return req.msg('请选择报名开始时间')
  610. }
  611. if (this.type==1 && !this.enlistEndTime) {
  612. return req.msg('请选择报名结束时间')
  613. }
  614. if (this.type==1 && !this.startTime) {
  615. return req.msg('请选择活动开始时间')
  616. }
  617. if (this.type==1 && !this.endTime) {
  618. return req.msg('请选择活动结束时间')
  619. }
  620. // if (!this.house) {
  621. // return req.msg('请填写活动地址')
  622. // }
  623. // if (this.regionCode.length == 0) {
  624. // return req.msg('请选择活动所在城市')
  625. // }
  626. // if (!this.address) {
  627. // return req.msg('请填写详细地址')
  628. // }
  629. let areaCodeList = []
  630. if(!this.isAllSee){
  631. this.industryList.map(item=>{
  632. item.children.map(it=>{
  633. if(it.isActive){
  634. areaCodeList.push({
  635. areaCode:it.value
  636. })
  637. }
  638. })
  639. })
  640. if(areaCodeList.length==0){
  641. return req.msg('请选择活动生效区域')
  642. }
  643. }else{
  644. areaCodeList.push({
  645. areaCode:this.companyTreeList[0].value
  646. })
  647. }
  648. let dataP = {
  649. pic: this.pic,
  650. fileList: JSON.stringify(this.fileList.map(item => {
  651. return {
  652. url: item
  653. }
  654. })),
  655. title: this.title,
  656. brief: this.brief,
  657. text: this.text,
  658. personLimit: this.personLimit,
  659. enlistPersonLimit:this.enlistPersonLimit,
  660. enlistStartTime: this.enlistStartTime,
  661. enlistEndTime: this.enlistEndTime,
  662. startTime: this.startTime,
  663. endTime: this.endTime,
  664. house: this.house,
  665. province: this.regionCode[0],
  666. city: this.regionCode[1],
  667. country: this.regionCode[2],
  668. areaAdd: this.region.join(','),
  669. address: this.address,
  670. lng: this.longitude,
  671. lat: this.latitude,
  672. areaCodeList:areaCodeList,
  673. type:this.type,
  674. matchType:this.matchType
  675. }
  676. let prices = [{
  677. title: "VIP",
  678. marketMoney: 0,
  679. money: 0,
  680. vipMoney: 0,
  681. vipModels: [],
  682. personCount: 1,
  683. isDefault: 0
  684. }]
  685. dataP.prices = prices
  686. dataP.extForm = this.extForm?this.extForm:null
  687. if(dataP.type==2){
  688. dataP.text = this.link
  689. }
  690. let url = '/api/match/save'
  691. if (this.id) {
  692. dataP.id = this.id
  693. url = '/api/match/update'
  694. uni.showModal({
  695. title: '提示',
  696. content: '修改活动将重新审核,确定修改?',
  697. success: (res) => {
  698. if (res.confirm) {
  699. req.postRequest(url, dataP, res => {
  700. req.msg('创建成功')
  701. let pages = getCurrentPages();
  702. var prevPage = pages[pages.length - 2];
  703. if (prevPage) {
  704. prevPage.$vm.isLoad = true
  705. prevPage.$vm.form.page = 1
  706. prevPage.$vm.getPageList()
  707. }
  708. setTimeout(() => {
  709. uni.navigateBack()
  710. }, 1000)
  711. })
  712. }
  713. }
  714. })
  715. } else {
  716. req.postRequest(url, dataP, res => {
  717. req.msg('创建成功')
  718. let pages = getCurrentPages();
  719. var prevPage = pages[pages.length - 2];
  720. if (prevPage) {
  721. prevPage.$vm.isLoad = true
  722. prevPage.$vm.form.page = 1
  723. prevPage.$vm.getPageList()
  724. }
  725. setTimeout(() => {
  726. uni.navigateBack()
  727. }, 1000)
  728. })
  729. }
  730. },
  731. formatTime(date) {
  732. date = new Date(date.replace(/-/g, '/'))
  733. return util.formatTime(date).t3
  734. },
  735. jian(){
  736. if(this.personLimit>0) this.personLimit = this.personLimit-1
  737. if(this.personLimit==0) this.personLimit = -1
  738. },
  739. jia(){
  740. if(this.personLimit==-1) this.personLimit = 1
  741. else this.personLimit = this.personLimit+1
  742. },
  743. jianEnlistPerson(){
  744. if(this.enlistPersonLimit>0) this.enlistPersonLimit = this.enlistPersonLimit-1
  745. if(this.enlistPersonLimit==0) this.enlistPersonLimit = -1
  746. },
  747. jiaEnlistPerson(){
  748. if(this.enlistPersonLimit==-1) this.enlistPersonLimit = 1
  749. else this.enlistPersonLimit = this.enlistPersonLimit+1
  750. },
  751. changeType(val){
  752. this.type = val
  753. }
  754. },
  755. mounted() {
  756. }
  757. }
  758. </script>
  759. <style>
  760. @import "./activityEdit.css";
  761. </style>