eadit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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);
  231. this.endTime=jkdata.endTime.slice(0,10);
  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. }
  255. //console.log(this.imgListArr)
  256. uni.setStorage({
  257. key: 'shopckList',
  258. data: useshoplist,
  259. success: function () {
  260. }
  261. });
  262. //this.list=res.data
  263. })
  264. },
  265. delimgzt(){
  266. this.img=''
  267. },
  268. upimgzt(){
  269. var that = this;
  270. uni.chooseImage({
  271. sourceType: ['album','camera'],
  272. count:1,
  273. success: (chooseImageRes) => {
  274. const tempFilePaths = chooseImageRes.tempFilePaths;
  275. that.file=tempFilePaths[0]
  276. uni.uploadFile({
  277. url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例,非真实的接口地址
  278. filePath: tempFilePaths[0],
  279. name: 'file',
  280. formData: {
  281. 'user': 'test'
  282. },
  283. success: (uploadFileRes) => {
  284. console.log(JSON.parse(uploadFileRes.data).data );
  285. that.img=JSON.parse(uploadFileRes.data).data[0]
  286. //that.imgArr=that.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
  287. //that.imgurl=JSON.parse(uploadFileRes.data).data[0];
  288. //that.goAddzdy(that.imgurl)
  289. }
  290. });
  291. }
  292. });
  293. },
  294. preview(){
  295. // if(this.money==0){
  296. // this.money=0
  297. // }
  298. console.log(this.money)
  299. if(this.activityName==''){
  300. uni.showToast({
  301. title: '请输入活动名称',
  302. icon:'none',
  303. duration: 2000
  304. });
  305. return false;
  306. }else if(!this.startTime||!this.endTime){
  307. uni.showToast({
  308. title: '请选择报名时间',
  309. icon:'none',
  310. duration: 2000
  311. });
  312. return false;
  313. }else if(this.shopList==''){
  314. uni.showToast({
  315. title: '请选择活动门店',
  316. icon:'none',
  317. duration: 2000
  318. });
  319. return false;
  320. }else if(this.clWhere==''){
  321. uni.showToast({
  322. title: '请选择报名凭证',
  323. icon:'none',
  324. duration: 2000
  325. });
  326. return false;
  327. }else if(this.number==''){
  328. uni.showToast({
  329. title: '请输入最多报名人数',
  330. icon:'none',
  331. duration: 2000
  332. });
  333. return false;
  334. }else if(this.money!=0&&this.money==''&&payType==1){
  335. uni.showToast({
  336. title: '请输入支付金额',
  337. icon:'none',
  338. duration: 2000
  339. });
  340. return false;
  341. }
  342. var editdata={
  343. id:this.id,
  344. activityName:this.activityName,
  345. startTime:this.startTime,
  346. endTime:this.endTime,
  347. number:this.number,
  348. activityContent:this.activityContent,
  349. clWhere:this.clWhereString,
  350. payType:this.payType,
  351. music:this.music,
  352. money:this.money,
  353. shopList:this.shopList,
  354. img:this.img,
  355. imgList:this.imgListArr.join(','),
  356. clState:'',
  357. }
  358. console.log(editdata)
  359. uni.setStorage({
  360. key: 'editdata',
  361. data: editdata,
  362. success: function () {
  363. uni.navigateTo({
  364. url:'jkDetail?type=1'
  365. })
  366. }
  367. });
  368. },
  369. addShop(){
  370. uni.navigateTo({
  371. url:'ckshop'
  372. })
  373. },
  374. goMusic(){
  375. uni.navigateTo({
  376. url:'ckmusic'
  377. })
  378. },
  379. musicDel(){
  380. this.music='';
  381. this.ckMusic=''
  382. uni.removeStorageSync('ckmusic');
  383. },
  384. bindTimeChangeStart(e){
  385. console.log(e)
  386. this.startTime=e.detail.value;
  387. },
  388. bindTimeChangeendTime(e){
  389. this.endTime=e.detail.value;
  390. },
  391. clWhere(num){
  392. this.clWhereString=this.clWhereList.join(',');
  393. if(this.clWhereString.indexOf(num)!=-1){
  394. // this.clWhereList.remove(num)
  395. let index = this.clWhereList.indexOf(num);
  396. this.clWhereList.splice(index, 1)
  397. //this.remove(num)
  398. }else{
  399. this.clWhereList.push(num)
  400. }
  401. this.clWhereString=this.clWhereList.join(',');
  402. console.log(this.clWhereString)
  403. },
  404. delimg(index){
  405. this.imgListArr.splice(index, 1)
  406. },
  407. upimg(){
  408. var that = this;
  409. uni.chooseImage({
  410. sourceType: ['album','camera'],
  411. count:9,
  412. success: (chooseImageRes) => {
  413. const tempFilePaths = chooseImageRes.tempFilePaths;
  414. that.file=tempFilePaths[0]
  415. uni.uploadFile({
  416. url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例,非真实的接口地址
  417. filePath: tempFilePaths[0],
  418. name: 'file',
  419. formData: {
  420. 'user': 'test'
  421. },
  422. success: (uploadFileRes) => {
  423. console.log(JSON.parse(uploadFileRes.data).data );
  424. that.imgListArr=that.imgListArr.concat(JSON.parse(uploadFileRes.data).data)
  425. //that.imgArr=that.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
  426. //that.imgurl=JSON.parse(uploadFileRes.data).data[0];
  427. //that.goAddzdy(that.imgurl)
  428. }
  429. });
  430. }
  431. });
  432. }
  433. }
  434. }
  435. </script>
  436. <style scoped>
  437. .content{
  438. min-height: 100vh;
  439. background:#F4F5F7;
  440. }
  441. .preview{
  442. width: 750rpx;
  443. height: 98rpx;
  444. background: #3F90F7;
  445. line-height: 98rpx;
  446. text-align: center;
  447. color: #ffffff;
  448. font-size: 30rpx;
  449. position: fixed;
  450. left: 0;
  451. bottom: 0;
  452. }
  453. .musicBox{
  454. padding: 0 24rpx;
  455. }
  456. .musicLine{
  457. display: flex;
  458. justify-content: space-between;
  459. margin-bottom:30rpx;
  460. padding:26rpx 24rpx;
  461. background: #F4F5F7;
  462. border-radius: 10rpx;
  463. }
  464. .musicName{
  465. color: #3C3C3C;font-size: 24rpx;
  466. padding-left: 10rpx;
  467. }
  468. .musicLineLeft{
  469. display: flex;
  470. }
  471. .musicDel{
  472. width: 30rpx;
  473. height: 30rpx;
  474. }
  475. .musicImg{
  476. width: 36rpx;
  477. height: 36rpx;
  478. }
  479. .line2{
  480. padding: 30rpx 24rpx;
  481. border-bottom: 1px solid #EEEEEE;
  482. }
  483. .musicJt{
  484. width: 28rpx;
  485. height: 28rpx;
  486. margin-top: 8rpx;
  487. }
  488. .musicRight{
  489. display: flex;
  490. justify-content: space-between;
  491. width: 500rpx;
  492. }
  493. .musicMS{
  494. color: #CCCCCC;
  495. }
  496. .lineimgdel{
  497. width: 37rpx;
  498. height: 37rpx;
  499. position: absolute;
  500. top: -18rpx;
  501. right: -18rpx;
  502. }
  503. .lineimghz{
  504. margin-right: 24rpx;
  505. position: relative;
  506. margin-top: 24rpx;
  507. }
  508. .lineimg{
  509. width: 150rpx;
  510. height: 150rpx;
  511. }
  512. .lineTitle{
  513. color: #666666;font-size: 28rpx;
  514. }
  515. .lineMS{
  516. color: #999999;font-size: 24rpx;padding-top: 10rpx;
  517. }
  518. .lineImgBOx{
  519. display: flex;
  520. flex-wrap: wrap;
  521. }
  522. .payBox{
  523. display: flex;
  524. }
  525. .payTypeImg{
  526. width: 36rpx;
  527. height: 36rpx;
  528. }
  529. .payType{
  530. display: flex;
  531. line-height: 36rpx;
  532. }
  533. .payTypeTxt{
  534. padding-left: 10rpx;
  535. color: #3C3C3C;
  536. }
  537. .line{
  538. display: flex;
  539. font-size: 28rpx;
  540. padding: 30rpx 24rpx;
  541. border-bottom: 1px solid #EEEEEE;
  542. }
  543. .linexx{
  544. color: #FF3B30;
  545. }
  546. .dateView{
  547. color:#3C3C3C ;
  548. }
  549. .lineLeft{
  550. width: 200rpx;
  551. color: #666666;
  552. }
  553. .clWhereBox{
  554. display: flex;
  555. }
  556. .clWhereLine{
  557. width: 100rpx;
  558. height: 52rpx;
  559. background: #F4F5F7;
  560. border-radius: 10rpx;
  561. text-align: center;
  562. color: #3C3C3C;
  563. line-height: 52rpx;
  564. font-size: 24rpx;
  565. margin-right: 24rpx;
  566. }
  567. .clWhereBox .clWhereActive{
  568. background: #EAF3FF;
  569. border: 2rpx solid #3F90F7;
  570. height: 48rpx;
  571. color: #3F90F7;
  572. height: 48rpx;
  573. line-height: 48rpx;
  574. width: 96rpx;
  575. }
  576. .timelineRight{
  577. display: flex;
  578. }
  579. .textsr{
  580. width: 500rpx;
  581. height: 180rpx;
  582. }
  583. .shopListNo{
  584. width: 400rpx;
  585. white-space:nowrap;
  586. overflow:hidden;
  587. text-overflow:ellipsis;
  588. color: #CCCCCC;
  589. }
  590. .shopListY{
  591. width: 400rpx;
  592. white-space:nowrap;
  593. overflow:hidden;
  594. text-overflow:ellipsis;
  595. color: #3C3C3C;
  596. }
  597. .addshop{
  598. color: #3F90F7;
  599. padding-left: 10rpx;
  600. }
  601. .shopckBox{
  602. display: flex;
  603. }
  604. .timeHx{
  605. color: #CCCCCC;
  606. padding: 0 30rpx;
  607. }
  608. .lineRightInput{
  609. font-size: 28rpx;
  610. color:#3C3C3C ;
  611. width: 500rpx;
  612. }
  613. .lineRight{
  614. color:#3C3C3C ;
  615. }
  616. .inputPlace{
  617. color: #CCCCCC;
  618. }
  619. .dateViewno{
  620. color: #CCCCCC;
  621. }
  622. .box{
  623. background: #ffffff;
  624. padding-bottom: 30rpx;
  625. }
  626. .kk{
  627. background:#F4F5F7;
  628. height: 20rpx;
  629. }
  630. .title{
  631. padding-left: 24rpx;
  632. padding-top: 30rpx;
  633. color: #333333;
  634. font-size: 32rpx;
  635. line-height: 45rpx;
  636. font-weight: 500;
  637. }
  638. .lineBorderNo{
  639. border-bottom: none !important;
  640. }
  641. </style>