eadit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. <template>
  2. <view class="content">
  3. <view class="kk"></view>
  4. <view class="box">
  5. <view class="title">基础信息</view>
  6. <view class="line">
  7. <view class="lineLeft">
  8. <span class="linexx">*</span> <span>活动名称</span>
  9. </view>
  10. <view class="lineRight">
  11. <input type="text" v-model="activityName" placeholder="请输入" class="lineRightInput" placeholder-class="inputPlace">
  12. </view>
  13. </view>
  14. <view class="line">
  15. <view class="lineLeft">
  16. <span class="linexx">*</span> <span>报名时间</span>
  17. </view>
  18. <view class="lineRight timelineRight">
  19. <picker mode="date" :value="startTime" @change="bindTimeChangeStart">
  20. <view class="dateViewno" v-if="!startTime">开始时间</view>
  21. <view class="dateView" v-else>{{startTime}}</view>
  22. </picker>
  23. <view class="timeHx">-</view>
  24. <picker mode="date" :value="endTime" @change="bindTimeChangeendTime">
  25. <view class="dateViewno" v-if="!endTime">结束时间</view>
  26. <view class="dateView" v-else>{{endTime}}</view>
  27. </picker>
  28. </view>
  29. </view>
  30. <view class="line">
  31. <view class="lineLeft">
  32. <span class="linexx">*</span> <span>活动门店</span>
  33. </view>
  34. <view class="lineRight shopckBox">
  35. <view class="shopListNo" v-if="!shopNames">请选择活动门店,可多选请</view>
  36. <view class="shopListY" v-if="shopNames">{{shopNames}}</view>
  37. <view class="addshop" @click="addShop">添加</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="kk"></view>
  42. <view class="box">
  43. <view class="title">报名信息</view>
  44. <view class="line">
  45. <view class="lineLeft">
  46. <span class="linexx">*</span> <span>报名凭证</span>
  47. </view>
  48. <view class="lineRight clWhereBox">
  49. <view class="clWhereLine" :class="{clWhereActive:clWhereString.indexOf(1)!=-1}" @click="clWhere(1)">手机号</view>
  50. <view class="clWhereLine" :class="{clWhereActive:clWhereString.indexOf(2)!=-1}" @click="clWhere(2)">车牌号</view>
  51. <view class="clWhereLine" :class="{clWhereActive:clWhereString.indexOf(3)!=-1}" @click="clWhere(3)">姓名</view>
  52. <view class="clWhereLine" :class="{clWhereActive:clWhereString.indexOf(4)!=-1}" @click="clWhere(4)">单位</view>
  53. </view>
  54. </view>
  55. <view class="line">
  56. <view class="lineLeft">
  57. <span class="linexx">*</span> <span>最多报名人数</span>
  58. </view>
  59. <view class="lineRight">
  60. <input type="number" v-model="number" placeholder="请输入" class="lineRightInput" placeholder-class="inputPlace">
  61. </view>
  62. </view>
  63. <view class="line">
  64. <view class="lineLeft">
  65. <span class="linexx">*</span> <span>支付方式</span>
  66. </view>
  67. <view class="lineRight payBox">
  68. <view class="payType" @click="payType=1">
  69. <img src="../../static/img/ckn.png" alt="" class="payTypeImg" v-if="payType!=1">
  70. <img src="../../static/img/cky.png" alt="" class="payTypeImg" v-if="payType==1">
  71. <view class="payTypeTxt">在线支付</view>
  72. </view>
  73. <view class="payType" @click="payType=2" style="padding-left: 30rpx;">
  74. <img src="../../static/img/cky.png" alt="" class="payTypeImg" v-if="payType==2">
  75. <img src="../../static/img/ckn.png" alt="" class="payTypeImg" v-if="payType!=2">
  76. <view class="payTypeTxt">无需支付</view>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="line" v-if="payType==1">
  81. <view class="lineLeft">
  82. <span class="linexx">*</span> <span>支付金额</span>
  83. </view>
  84. <view class="lineRight">
  85. <input type="text" v-model="money" placeholder="请输入" class="lineRightInput" placeholder-class="inputPlace">
  86. </view>
  87. </view>
  88. </view>
  89. <view class="kk"></view>
  90. <view class="box">
  91. <view class="title">活动详情</view>
  92. <view class="line">
  93. <view class="lineLeft">
  94. <span>活动说明</span>
  95. </view>
  96. <view class="lineRight">
  97. <textarea placeholder-class="inputPlace" v-model="activityContent" placeholder="请输入" class="textsr"/>
  98. </view>
  99. </view>
  100. <view class="line2">
  101. <view class="lineTitle">主图</view>
  102. <view class="lineMS">此图在活动顶部显示,建议宽度750px</view>
  103. <view class="lineImgBOx">
  104. <view class="lineimghz" v-if="img" >
  105. <img src="../../static/img/del.png" alt="" class="lineimgdel" @click="delimgzt" >
  106. <img :src="img" alt="" class="lineimg" @click="previewImage(img)">
  107. </view>
  108. <view class="lineimghz" @click="upimgzt" v-if="!img">
  109. <img src="../../static/img/scimg.png" alt="" class="lineimg">
  110. </view>
  111. </view>
  112. </view>
  113. <view class="line2">
  114. <view class="lineTitle">详情图片</view>
  115. <view class="lineMS">此图在活动底部显示,可用于显示门店照片等,建议宽度750px</view>
  116. <view class="lineImgBOx">
  117. <view class="lineimghz" v-for="(item,index) in imgListArr">
  118. <img src="../../static/img/del.png" alt="" class="lineimgdel" @click="delimg(index)" >
  119. <img :src="item" alt="" class="lineimg" @click="previewImage(item)">
  120. </view>
  121. <view class="lineimghz" @click="upimg">
  122. <img src="../../static/img/scimg.png" alt="" class="lineimg">
  123. </view>
  124. </view>
  125. </view>
  126. <view class="line lineBorderNo">
  127. <view class="lineLeft">
  128. <span>音乐</span>
  129. </view>
  130. <view class="lineRight musicRight" @click="goMusic">
  131. <view class="musicMS">选择/更换音乐</view>
  132. <img src="../../static/img/jt.png" alt="" class="musicJt">
  133. </view>
  134. </view>
  135. <view class="musicBox" v-if="ckMusic">
  136. <view class="musicLine">
  137. <view class="musicLineLeft">
  138. <img src="../../static/img/music.png" alt="" class="musicImg">
  139. <view class="musicName">{{ckMusic.name}}</view>
  140. </view>
  141. <view>
  142. <img src="../../static/img/sanchu.png" alt="" class="musicDel" @click="musicDel">
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. <view style="height: 120rpx;"></view>
  148. <view class="preview" @click="preview">预览</view>
  149. </view>
  150. </template>
  151. <script>
  152. export default {
  153. data() {
  154. return {
  155. id:'', //类型:String 可有字段 备注:新增无编辑有
  156. activityName:'', //类型:String 必有字段 备注:活动名称
  157. startTime:"", //类型:String 必有字段 备注:营业开始时间
  158. endTime:"", //类型:String 必有字段 备注:营业结束时间
  159. number:"", //类型:String 必有字段 备注:报名人数
  160. activityContent:"", //类型:String 必有字段 备注:活动说明
  161. //clWhere:'', //类型:String 必有字段 备注:报名凭证1,2,3,4 1手机号2车牌号3姓名4单位
  162. payType:1, //类型:String 必有字段 备注:1在线支付2无需支付
  163. music:"", //类型:String 必有字段 备注:背景音乐
  164. clState:'', //类型:String 必有字段 备注:1未启用2启用
  165. img:'', //类型:String 必有字段 备注:从首页带进来的图片
  166. imgList:'',//类型:String 必有字段 备注:详情图片多个以逗号分割
  167. datetimerange: '',
  168. shopNames:'',
  169. shopList:'',
  170. clWhereList:[],
  171. clWhereString:'',
  172. imgListArr:[],
  173. money:'',
  174. ckMusic:'',
  175. id:'',
  176. }
  177. },
  178. onLoad(opt) {
  179. this.img=opt.img;
  180. if(opt.id){
  181. this.id=opt.id;
  182. this.getDetails()
  183. }
  184. },
  185. onShow() {
  186. const shopckList = uni.getStorageSync("shopckList");
  187. this.ckMusic=uni.getStorageSync("ckmusic")
  188. if(this.ckMusic){
  189. this.music=this.ckMusic.id
  190. }
  191. var shopNames=[];
  192. var shopList=[];
  193. if(shopckList){
  194. shopckList.forEach(item=>{
  195. shopNames.push(item.shopName)
  196. shopList.push(item.id)
  197. })
  198. this.shopNames=shopNames.join(',')
  199. this.shopList=shopList.join(',')
  200. }
  201. },
  202. methods: {
  203. previewImage(img){
  204. var arr=[]
  205. arr.push(img)
  206. uni.previewImage({
  207. urls: arr,
  208. longPressActions: {
  209. itemList: ['发送给朋友', '保存图片',],
  210. success: function(data) {},
  211. fail: function(err) {}
  212. }
  213. });
  214. },
  215. getDetails(){
  216. uni.showLoading({
  217. title: '加载中'
  218. })
  219. this.$http('openH5SetTheGuest/getAtivityDetails', {
  220. id:this.id
  221. },'GET').then(res => {
  222. uni.hideLoading();
  223. var jkdata=res.data.data
  224. this.activityName=jkdata.activityName;
  225. this.activityContent=jkdata.activityContent;
  226. this.money=jkdata.money;
  227. this.number=jkdata.number;
  228. this.clWhereString=jkdata.clWhere;
  229. this.clWhereList=this.clWhereString.slice(',');
  230. this.startTime=jkdata.startTime.slice(0,10)+ ' 00:00:00';
  231. this.endTime=jkdata.endTime.slice(0,10)+ ' 23:59:59';
  232. this.payType=jkdata.payType;
  233. this.img=res.data.img.img;
  234. if(res.data.imgList){
  235. res.data.imgList.forEach(item=>{
  236. this.imgListArr.push(item.img)
  237. })
  238. }
  239. var shopNames=[];
  240. var shopList=[];
  241. if(res.data.shopList){
  242. res.data.shopList.forEach(item=>{
  243. item.id=item.shopId
  244. shopNames.push(item.shopName)
  245. shopList.push(item.shopId)
  246. })
  247. this.shopNames=shopNames.join(',')
  248. this.shopList=shopList.join(',')
  249. }
  250. var useshoplist=res.data.shopList
  251. this.ckMusic=res.data.selectedMusic;
  252. if(this.ckMusic){
  253. this.music=this.ckMusic.id;
  254. uni.setStorage({
  255. key: 'ckmusic',
  256. data: this.ckMusic,
  257. success: function () {
  258. }
  259. });
  260. }else{
  261. uni.removeStorageSync('ckmusic');
  262. }
  263. //console.log(this.imgListArr)
  264. uni.setStorage({
  265. key: 'shopckList',
  266. data: useshoplist,
  267. success: function () {
  268. }
  269. });
  270. //this.list=res.data
  271. })
  272. },
  273. delimgzt(){
  274. this.img=''
  275. },
  276. upimgzt(){
  277. var that = this;
  278. uni.chooseImage({
  279. sourceType: ['album','camera'],
  280. count:1,
  281. success: (chooseImageRes) => {
  282. const tempFilePaths = chooseImageRes.tempFilePaths;
  283. that.file=tempFilePaths[0]
  284. uni.uploadFile({
  285. url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例,非真实的接口地址
  286. filePath: tempFilePaths[0],
  287. name: 'file',
  288. formData: {
  289. 'user': 'test'
  290. },
  291. success: (uploadFileRes) => {
  292. console.log(JSON.parse(uploadFileRes.data).data );
  293. that.img=JSON.parse(uploadFileRes.data).data[0]
  294. //that.imgArr=that.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
  295. //that.imgurl=JSON.parse(uploadFileRes.data).data[0];
  296. //that.goAddzdy(that.imgurl)
  297. }
  298. });
  299. }
  300. });
  301. },
  302. preview(){
  303. //console.log(this.clWhere)
  304. // if(this.money==0){
  305. // this.money=0
  306. // }
  307. console.log(this.money)
  308. if(this.activityName==''){
  309. uni.showToast({
  310. title: '请输入活动名称',
  311. icon:'none',
  312. duration: 2000
  313. });
  314. return false;
  315. }else if(!this.startTime||!this.endTime){
  316. uni.showToast({
  317. title: '请选择报名时间',
  318. icon:'none',
  319. duration: 2000
  320. });
  321. return false;
  322. }else if(this.shopList==''){
  323. uni.showToast({
  324. title: '请选择活动门店',
  325. icon:'none',
  326. duration: 2000
  327. });
  328. return false;
  329. }else if(this.clWhereString==''){
  330. uni.showToast({
  331. title: '请选择报名凭证',
  332. icon:'none',
  333. duration: 2000
  334. });
  335. return false;
  336. }else if(this.number==''){
  337. uni.showToast({
  338. title: '请输入最多报名人数',
  339. icon:'none',
  340. duration: 2000
  341. });
  342. return false;
  343. }else if(this.money!==0&&this.money==''&&this.payType==1){
  344. uni.showToast({
  345. title: '请输入支付金额',
  346. icon:'none',
  347. duration: 2000
  348. });
  349. return false;
  350. }
  351. //return false;
  352. var editdata={
  353. id:this.id,
  354. activityName:this.activityName,
  355. startTime:this.startTime+ ' 00:00:00',
  356. endTime:this.endTime+ ' 23:59:59',
  357. number:this.number,
  358. activityContent:this.activityContent,
  359. clWhere:this.clWhereString,
  360. payType:this.payType,
  361. music:this.music,
  362. money:this.money,
  363. shopList:this.shopList,
  364. img:this.img,
  365. imgList:this.imgListArr.join(','),
  366. clState:'',
  367. }
  368. console.log(editdata)
  369. uni.setStorage({
  370. key: 'editdata',
  371. data: editdata,
  372. success: function () {
  373. uni.navigateTo({
  374. url:'jkDetail?type=1'
  375. })
  376. }
  377. });
  378. },
  379. addShop(){
  380. uni.navigateTo({
  381. url:'ckshop'
  382. })
  383. },
  384. goMusic(){
  385. uni.navigateTo({
  386. url:'ckmusic'
  387. })
  388. },
  389. musicDel(){
  390. this.music='';
  391. this.ckMusic=''
  392. uni.removeStorageSync('ckmusic');
  393. },
  394. bindTimeChangeStart(e){
  395. console.log(e)
  396. this.startTime=e.detail.value;
  397. },
  398. bindTimeChangeendTime(e){
  399. this.endTime=e.detail.value;
  400. },
  401. clWhere(num){
  402. this.clWhereString=this.clWhereList.join(',');
  403. if(this.clWhereString.indexOf(num)!=-1){
  404. // this.clWhereList.remove(num)
  405. let index = this.clWhereList.indexOf(num);
  406. this.clWhereList.splice(index, 1)
  407. //this.remove(num)
  408. }else{
  409. this.clWhereList.push(num)
  410. }
  411. this.clWhereString=this.clWhereList.join(',');
  412. console.log(this.clWhereString)
  413. },
  414. delimg(index){
  415. this.imgListArr.splice(index, 1)
  416. },
  417. upimg(){
  418. var that = this;
  419. uni.chooseImage({
  420. sourceType: ['album','camera'],
  421. count:9,
  422. success: (chooseImageRes) => {
  423. const tempFilePaths = chooseImageRes.tempFilePaths;
  424. that.file=tempFilePaths[0]
  425. uni.uploadFile({
  426. url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例,非真实的接口地址
  427. filePath: tempFilePaths[0],
  428. name: 'file',
  429. formData: {
  430. 'user': 'test'
  431. },
  432. success: (uploadFileRes) => {
  433. console.log(JSON.parse(uploadFileRes.data).data );
  434. that.imgListArr=that.imgListArr.concat(JSON.parse(uploadFileRes.data).data)
  435. //that.imgArr=that.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
  436. //that.imgurl=JSON.parse(uploadFileRes.data).data[0];
  437. //that.goAddzdy(that.imgurl)
  438. }
  439. });
  440. }
  441. });
  442. }
  443. }
  444. }
  445. </script>
  446. <style scoped>
  447. .content{
  448. min-height: 100vh;
  449. background:#F4F5F7;
  450. }
  451. .preview{
  452. width: 750rpx;
  453. height: 98rpx;
  454. background: #3F90F7;
  455. line-height: 98rpx;
  456. text-align: center;
  457. color: #ffffff;
  458. font-size: 30rpx;
  459. position: fixed;
  460. left: 0;
  461. bottom: 0;
  462. }
  463. .musicBox{
  464. padding: 0 24rpx;
  465. }
  466. .musicLine{
  467. display: flex;
  468. justify-content: space-between;
  469. margin-bottom:30rpx;
  470. padding:26rpx 24rpx;
  471. background: #F4F5F7;
  472. border-radius: 10rpx;
  473. }
  474. .musicName{
  475. color: #3C3C3C;font-size: 24rpx;
  476. padding-left: 10rpx;
  477. }
  478. .musicLineLeft{
  479. display: flex;
  480. }
  481. .musicDel{
  482. width: 30rpx;
  483. height: 30rpx;
  484. }
  485. .musicImg{
  486. width: 36rpx;
  487. height: 36rpx;
  488. }
  489. .line2{
  490. padding: 30rpx 24rpx;
  491. border-bottom: 1px solid #EEEEEE;
  492. }
  493. .musicJt{
  494. width: 28rpx;
  495. height: 28rpx;
  496. margin-top: 8rpx;
  497. }
  498. .musicRight{
  499. display: flex;
  500. justify-content: space-between;
  501. width: 500rpx;
  502. }
  503. .musicMS{
  504. color: #CCCCCC;
  505. }
  506. .lineimgdel{
  507. width: 37rpx;
  508. height: 37rpx;
  509. position: absolute;
  510. top: -18rpx;
  511. right: -18rpx;
  512. }
  513. .lineimghz{
  514. margin-right: 24rpx;
  515. position: relative;
  516. margin-top: 24rpx;
  517. }
  518. .lineimg{
  519. width: 150rpx;
  520. height: 150rpx;
  521. }
  522. .lineTitle{
  523. color: #666666;font-size: 28rpx;
  524. }
  525. .lineMS{
  526. color: #999999;font-size: 24rpx;padding-top: 10rpx;
  527. }
  528. .lineImgBOx{
  529. display: flex;
  530. flex-wrap: wrap;
  531. }
  532. .payBox{
  533. display: flex;
  534. }
  535. .payTypeImg{
  536. width: 36rpx;
  537. height: 36rpx;
  538. }
  539. .payType{
  540. display: flex;
  541. line-height: 36rpx;
  542. }
  543. .payTypeTxt{
  544. padding-left: 10rpx;
  545. color: #3C3C3C;
  546. }
  547. .line{
  548. display: flex;
  549. font-size: 28rpx;
  550. padding: 30rpx 24rpx;
  551. border-bottom: 1px solid #EEEEEE;
  552. }
  553. .linexx{
  554. color: #FF3B30;
  555. }
  556. .dateView{
  557. color:#3C3C3C ;
  558. }
  559. .lineLeft{
  560. width: 200rpx;
  561. color: #666666;
  562. }
  563. .clWhereBox{
  564. display: flex;
  565. }
  566. .clWhereLine{
  567. width: 100rpx;
  568. height: 52rpx;
  569. background: #F4F5F7;
  570. border-radius: 10rpx;
  571. text-align: center;
  572. color: #3C3C3C;
  573. line-height: 52rpx;
  574. font-size: 24rpx;
  575. margin-right: 24rpx;
  576. }
  577. .clWhereBox .clWhereActive{
  578. background: #EAF3FF;
  579. border: 2rpx solid #3F90F7;
  580. height: 48rpx;
  581. color: #3F90F7;
  582. height: 48rpx;
  583. line-height: 48rpx;
  584. width: 96rpx;
  585. }
  586. .timelineRight{
  587. display: flex;
  588. }
  589. .textsr{
  590. width: 500rpx;
  591. height: 180rpx;
  592. }
  593. .shopListNo{
  594. width: 400rpx;
  595. white-space:nowrap;
  596. overflow:hidden;
  597. text-overflow:ellipsis;
  598. color: #CCCCCC;
  599. }
  600. .shopListY{
  601. width: 400rpx;
  602. white-space:nowrap;
  603. overflow:hidden;
  604. text-overflow:ellipsis;
  605. color: #3C3C3C;
  606. }
  607. .addshop{
  608. color: #3F90F7;
  609. padding-left: 10rpx;
  610. }
  611. .shopckBox{
  612. display: flex;
  613. }
  614. .timeHx{
  615. color: #CCCCCC;
  616. padding: 0 30rpx;
  617. }
  618. .lineRightInput{
  619. font-size: 28rpx;
  620. color:#3C3C3C ;
  621. width: 500rpx;
  622. }
  623. .lineRight{
  624. color:#3C3C3C ;
  625. }
  626. .inputPlace{
  627. color: #CCCCCC;
  628. }
  629. .dateViewno{
  630. color: #CCCCCC;
  631. }
  632. .box{
  633. background: #ffffff;
  634. padding-bottom: 30rpx;
  635. }
  636. .kk{
  637. background:#F4F5F7;
  638. height: 20rpx;
  639. }
  640. .title{
  641. padding-left: 24rpx;
  642. padding-top: 30rpx;
  643. color: #333333;
  644. font-size: 32rpx;
  645. line-height: 45rpx;
  646. font-weight: 500;
  647. }
  648. .lineBorderNo{
  649. border-bottom: none !important;
  650. }
  651. </style>