index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. <template>
  2. <view :style="colorStyle">
  3. <form @submit="formSubmit">
  4. <view class='addAddress'>
  5. <view class='list'>
  6. <view class='item acea-row row-between-wrapper'>
  7. <view class='name'>主标题</view>
  8. <input type='text' placeholder='请填写主标题' name='mainTitle' :value="grouponReqData.mainTitle"
  9. placeholder-class='placeholder'></input>
  10. </view>
  11. <view class='item acea-row row-between-wrapper'>
  12. <view class='name'>副标题</view>
  13. <input type='text' placeholder='请填写副标题' name="subTitle" :value='grouponReqData.subTitle'
  14. placeholder-class='placeholder'></input>
  15. </view>
  16. </view>
  17. <view class="list" style="margin-top:50rpx;">
  18. <view class="title">
  19. 团购商品
  20. </view>
  21. <view class='item acea-row row-between-wrapper'>
  22. <view class='name'>团购时间</view>
  23. <view @click="show1 = true">
  24. <uni-datetime-picker @change="confirmDate1" v-model="datetimerange1" type="datetimerange"
  25. rangeSeparator="至">
  26. <input placeholder='请选择团购时间' disabled :value='grouponDateTime' placeholder-class='placeholder'></input>
  27. </uni-datetime-picker>
  28. </view>
  29. </view>
  30. <view class='item acea-row row-between-wrapper'>
  31. <view class='name'>提货时间</view>
  32. <view @click="show2 = true">
  33. <uni-datetime-picker @change="confirmDate2" v-model="datetimerange2" type="datetimerange"
  34. rangeSeparator="至">
  35. <input placeholder='请选择提货时间' disabled :value='takeDateTime' placeholder-class='placeholder'></input>
  36. </uni-datetime-picker>
  37. </view>
  38. <!-- <u-datetime-picker @confirm="dateConfirmDate2()" :show="show2" v-model="value1"
  39. mode="datetimerange"></u-datetime-picker> -->
  40. </view>
  41. <view class='item acea-row row-between-wrapper'>
  42. <view class='name'>自提点</view>
  43. <view @click="openSelfTakeTable()">
  44. <input type='text' placeholder='请选择提自提点' disabled v-model="ztd"
  45. placeholder-class='placeholder'></input>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="list select-list" v-if="selectGoodList.length > 0">
  50. <view class="title">
  51. 团购商品
  52. </view>
  53. <view class="all-products-body" v-for="(itemn, indexn) in selectGoodList" :key="indexn">
  54. <view class="all-products-item">
  55. <image :src='itemn.goodsCover' v-if="itemn.goodsCover"></image>
  56. <image src="/static/images/sort-img.png" v-else></image>
  57. <view class="all-products-item-content">
  58. <view class="all-products-item-content-t">
  59. {{ itemn.goodsName }}
  60. </view>
  61. <view class="all-products-item-content-b">
  62. <view style="display:flex; flex-grow: 1;">
  63. <text class="red"> ¥{{ itemn.discountPrice }}</text>
  64. </view>
  65. <view @click="delItem(indexn)" class="count">
  66. <image
  67. src="http://www.gzzzyd.com/groupon/home_slices/错误@2x.png"
  68. mode="scaleToFill"
  69. />
  70. </view>
  71. <view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <button class="button_1 flex-col justify-center" @click="addGood">
  79. <text class="text_15">添加商品</text>
  80. </button>
  81. <button class='keepBnt' form-type="submit">保存并提交</button>
  82. </view>
  83. </form>
  84. <!-- #ifdef MP -->
  85. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  86. <!-- #endif -->
  87. <!-- #ifndef MP -->
  88. <home></home>
  89. <!-- #endif -->
  90. <u-popup :show="addGoodPopupShow" @close="close" @open="">
  91. <view>
  92. <publish_good_list ref="publish_good_list" @getSelectData="getSelectData" v-if="addGoodPopupShow"></publish_good_list>
  93. </view>
  94. </u-popup>
  95. <u-popup :show="selfTakeShow" @close="selfTakeShow = false">
  96. <view class="box_3 flex-col">
  97. <view class="flex-row justify-between">
  98. <text class="icon_2" @click="closeFalse()">取消</text>
  99. <text class="icon_2" @click="closeTrue()">确定</text>
  100. </view>
  101. <text class="text_25">选择自提点</text>
  102. <scroll-view scroll-y="true" class="scroll-y">
  103. <view class="list_1 flex-col">
  104. <view @click="clickSelfTake(item,index)"
  105. class="list-items_1 flex-row"
  106. v-for="(item, index) in selfTakeList"
  107. :key="index">
  108. <view class="flex-col justify-center">
  109. <view v-if="item.addressTrue" class="image-view">
  110. <image class="image" src="/static/images/v.png"></image>
  111. </view>
  112. <view v-else class="image-view " >
  113. <image class="image" src="/static/images/o.png"></image>
  114. </view>
  115. </view>
  116. <view class="dataGroup">
  117. <view class="group_14 flex-row justify-between">
  118. <view class="flex-col">
  119. <text class="text_26" >{{item.name}}</text>
  120. <text class="text_27" >{{item.address}}</text>
  121. </view>
  122. <view class="flex-row justify-between">
  123. <text class="text-group_9" >距您{{item.distanceDesc}}</text>
  124. <image class="icon_3"
  125. src="http://www.gzzzyd.com/groupon/order_details/距离@2x.png"/>
  126. </view>
  127. </view>
  128. <view class="group_15 flex-row">
  129. <view class="tag_1 flex-col">
  130. <text class="text_28">营业时间: {{item.busStartTimeDesc}}-{{item.busEndTimeDesc}}</text>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. </scroll-view>
  137. </view>
  138. </u-popup>
  139. </view>
  140. </template>
  141. <script>
  142. import { publishGroupon, getAllSelfTake } from '@/api/groupon.js';
  143. import {
  144. toLogin
  145. } from '@/libs/login.js';
  146. import {
  147. mapGetters
  148. } from "vuex";
  149. // #ifdef MP
  150. import authorize from '@/components/Authorize';
  151. // #endif
  152. import home from '@/components/home';
  153. import publish_good_list from '../publish_good_list/index.vue';
  154. import colors from '@/mixins/color.js';
  155. import {forEach} from "../../../uni_modules/uview-ui/libs/luch-request/utils";
  156. export default {
  157. components: {
  158. // #ifdef MP
  159. authorize,
  160. // #endif
  161. home,
  162. publish_good_list
  163. },
  164. mixins: [colors],
  165. data () {
  166. return {
  167. ztd:'',
  168. selfTakeShow:false,
  169. grouponDateTime: '',
  170. takeDateTime: '',
  171. datetimerange1: '',
  172. datetimerange2: '',
  173. grouponReqData: {
  174. mainTitle: '',
  175. subTitle: '',
  176. grouponStartTime: '',
  177. grouponEndTime: '',
  178. takeStartTime: '',
  179. takeEndTime: '',
  180. selfTakeIds: [],
  181. goodsIds: []
  182. },
  183. grouponTimeRange: [],
  184. takeTimeRange: [],
  185. array: [],
  186. show1: false,
  187. show2: false,
  188. showZTD: false,
  189. addGoodPopupShow: false,
  190. id: 0, //地址id
  191. district: [],
  192. multiArray: [],
  193. multiIndex: [0, 0, 0],
  194. cityId: 0,
  195. news: '',
  196. noCoupon: 0,
  197. selectGoodList: [],
  198. selfTakeList: [],
  199. addressIds:[]
  200. };
  201. },
  202. computed: mapGetters(['isLogin']),
  203. watch: {
  204. isLogin: {
  205. handler: function (newV, oldV) {
  206. if (newV) {
  207. this.getUserAddress();
  208. }
  209. },
  210. deep: true
  211. }
  212. },
  213. onLoad (options) {
  214. if (this.isLogin) {
  215. this.id = options.id || 0;
  216. uni.setNavigationBarTitle({
  217. title: '发布团购'
  218. })
  219. // this.getUserAddress();
  220. // this.getCityList();
  221. } else {
  222. toLogin();
  223. }
  224. },
  225. methods: {
  226. closeFalse(){
  227. this.selfTakeShow = false;
  228. },
  229. closeTrue(){
  230. this.selfTakeShow = false;
  231. let _ztd=''
  232. console.log(this.grouponReqData.selfTakeIds)
  233. this.selfTakeList.forEach(e =>{
  234. this.grouponReqData.selfTakeIds.forEach(ee =>{
  235. if (e.id === ee){
  236. if (_ztd){
  237. _ztd=_ztd +','+e.name
  238. }else {
  239. _ztd=e.name
  240. }
  241. }
  242. })
  243. })
  244. this.ztd = _ztd
  245. console.log(this.ztd)
  246. },
  247. clickSelfTake(item,index){
  248. item.addressTrue = !item.addressTrue;
  249. this.$set(this.selfTakeList,index,item)
  250. if (this.grouponReqData.selfTakeIds.indexOf(item.id) === -1){
  251. this.grouponReqData.selfTakeIds.push(item.id)
  252. }else {
  253. this.grouponReqData.selfTakeIds = this.grouponReqData.selfTakeIds.filter(iter => iter !== item.id)
  254. }
  255. },
  256. confirmDate1 (value) {
  257. let start = value[0];
  258. let end = value[1];
  259. this.grouponReqData.grouponStartTime = start;
  260. this.grouponReqData.grouponEndTime = end;
  261. this.grouponDateTime = start.substr(5, 2) + "/" + start.substr(8, 2) + " " + start.substr(11, 5) + " 至 "
  262. + end.substr(5, 2) + "/" + end.substr(8, 2) + " " + end.substr(11, 5);
  263. },
  264. confirmDate2 (value) {
  265. let start = value[0];
  266. let end = value[1];
  267. this.grouponReqData.takeStartTime = start;
  268. this.grouponReqData.takeEndTime = end;
  269. this.takeDateTime = start.substr(5, 2) + "/" + start.substr(8, 2) + " " + start.substr(11, 5) + " 至 "
  270. + end.substr(5, 2) + "/" + end.substr(8, 2) + " " + end.substr(11, 5);
  271. },
  272. selectDatetime () {
  273. this.$refs.mySon.show();
  274. },
  275. openSelfTakeTable () {
  276. this.grouponReqData.selfTakeIds = []
  277. getAllSelfTake({
  278. current: 1,
  279. size: 50
  280. }).then(res => {
  281. this.selfTakeShow = true;
  282. console.log(res.data);
  283. this.selfTakeList=res.data.records;
  284. console.log(this.selfTakeList);
  285. })
  286. },
  287. delItem (index) {
  288. this.selectGoodList.splice(index, 1)
  289. },
  290. getSelectData (data) {
  291. console.log("getSelectData ", data)
  292. this.selectGoodList = data
  293. console.log(this.selectGoodList);
  294. },
  295. open () {
  296. // console.log('open');
  297. },
  298. close () {
  299. this.addGoodPopupShow = false
  300. this.grouponReqData.goodsIds =this.$refs.publish_good_list.returnVGoodIds();
  301. console.log('close',this.grouponReqData.goodsIds);
  302. },
  303. addGood () {
  304. this.addGoodPopupShow = true
  305. },
  306. bindPickerChange: function (e) {
  307. this.index = e.detail.value;
  308. },
  309. dateConfirm (value) {
  310. console.log('dateConfirm! ', value)
  311. this.userAddress.date = value.value
  312. this.show1 = false
  313. },
  314. dateConfirmDate2 (value) {
  315. this.userAddress.date2 = value.value
  316. this.show2 = false
  317. },
  318. confirmZTD (value) {
  319. console.log(value)
  320. this.ztd = value.value[0].name;
  321. this.grouponReqData.selfTakeIds.push(value.value[0].id)
  322. this.showZTD = false
  323. },
  324. // #ifdef APP-PLUS
  325. // 获取选择的地区
  326. handleGetRegion (region) {
  327. this.region = region
  328. },
  329. // #endif
  330. onConfirm (val) {
  331. this.region = val.checkArr[0] + '-' + val.checkArr[1] + '-' + val.checkArr[2];
  332. },
  333. /**
  334. * 发布团购
  335. */
  336. formSubmit: function (e) {
  337. let that = this,
  338. value = e.detail.value;
  339. if (!value.mainTitle.trim()) {
  340. return that.$util.Tips({
  341. title: that.$t(`请填写主标题`)
  342. });
  343. }
  344. that.grouponReqData.mainTitle = value.mainTitle;
  345. if (!value.subTitle.trim()) {
  346. return that.$util.Tips({
  347. title: that.$t(`请填写副标题`)
  348. });
  349. }
  350. that.grouponReqData.subTitle = value.subTitle;
  351. if (!that.grouponReqData.grouponStartTime.trim() || !that.grouponReqData.grouponEndTime.trim()) {
  352. return that.$util.Tips({
  353. title: that.$t(`请选择团购时间`)
  354. });
  355. }
  356. if (!that.grouponReqData.takeStartTime.trim() || !that.grouponReqData.takeEndTime.trim()) {
  357. return that.$util.Tips({
  358. title: that.$t(`请选择取货时间`)
  359. });
  360. }
  361. if (that.grouponReqData.selfTakeIds.length < 1) {
  362. return that.$util.Tips({
  363. title: that.$t(`请选择自提点`)
  364. });
  365. }
  366. if (this.grouponReqData.goodsIds.length < 1) {
  367. return that.$util.Tips({
  368. title: that.$t(`请添加商品`)
  369. });
  370. }
  371. // let goodsIds = [];
  372. // this.selectGoodList.forEach(e => {
  373. // goodsIds.push(e.id);
  374. // that.grouponReqData.goodsIds = goodsIds;
  375. // })
  376. uni.showLoading({
  377. title: that.$t(`发布中`),
  378. mask: true
  379. })
  380. let resSuccess = false;
  381. publishGroupon(that.grouponReqData).then(res => {
  382. that.$util.Tips({
  383. title: that.$t(`提交成功`),
  384. icon: 'success'
  385. });
  386. resSuccess = true
  387. }).catch(err => {
  388. return that.$util.Tips({
  389. title: err
  390. });
  391. })
  392. },
  393. }
  394. }
  395. </script>
  396. <style scoped lang="scss">
  397. @import "/static/css/common.css";
  398. .fontcolor {
  399. color: var(--view-theme);
  400. }
  401. .addAddress .list {
  402. background-color: #fff;
  403. padding-top: 10rpx;
  404. .title {
  405. margin: 30rpx;
  406. height: 44rpx;
  407. font-size: 32rpx;
  408. font-weight: bolder;
  409. color: #111111;
  410. line-height: 44rpx;
  411. }
  412. }
  413. .addAddress .list .item {
  414. padding: 30rpx;
  415. border-top: 1rpx solid #eee;
  416. }
  417. .addAddress .list .item .name {
  418. width: 195rpx;
  419. font-size: 30rpx;
  420. color: #333;
  421. }
  422. .addAddress .list .item .address {
  423. // width: 412rpx;
  424. flex: 1;
  425. margin-left: 20rpx;
  426. }
  427. .addAddress .list .item input {
  428. width: 475rpx;
  429. font-size: 30rpx;
  430. }
  431. .addAddress .list .item .placeholder {
  432. color: #ccc;
  433. }
  434. .addAddress .list .item picker {
  435. width: 475rpx;
  436. }
  437. .addAddress .list .item picker .picker {
  438. width: 410rpx;
  439. font-size: 30rpx;
  440. }
  441. .addAddress .list .item picker .iconfont {
  442. font-size: 43rpx;
  443. }
  444. .addAddress .default {
  445. padding: 0 30rpx;
  446. height: 90rpx;
  447. background-color: #fff;
  448. margin-top: 23rpx;
  449. }
  450. .addAddress .default checkbox {
  451. margin-right: 15rpx;
  452. }
  453. .addAddress .keepBnt {
  454. width: 90%;
  455. height: 84rpx;
  456. background: #B42A3E;
  457. border-radius: 8rpx;
  458. margin: 30rpx auto;
  459. font-size: 28rpx;
  460. font-weight: 400;
  461. color: #FFFFFF;
  462. line-height: 84rpx;
  463. }
  464. .addAddress .wechatAddress {
  465. width: 690rpx;
  466. height: 86rpx;
  467. border-radius: 50rpx;
  468. text-align: center;
  469. line-height: 86rpx;
  470. margin: 0 auto;
  471. font-size: 32rpx;
  472. color: var(--view-theme);
  473. border: 1px solid var(--view-theme);
  474. }
  475. .button_1 {
  476. width: 90%;
  477. height: 84rpx;
  478. background: #FFFFFF;
  479. border-radius: 8rpx;
  480. border: 2rpx solid #B42A3E;
  481. margin: 30rpx auto;
  482. font-size: 28rpx;
  483. font-weight: 400;
  484. color: #B42A3E;
  485. line-height: 84rpx;
  486. }
  487. .text_15 {
  488. overflow-wrap: break-word;
  489. color: rgba(180, 42, 62, 1);
  490. font-size: 14px;
  491. font-weight: NaN;
  492. text-align: center;
  493. white-space: nowrap;
  494. line-height: 20px;
  495. }
  496. .acea-row-item {
  497. display: flex;
  498. width: 100% !important;
  499. flex-direction: row;
  500. .picture {
  501. width: 120rpx;
  502. height: 120rpx;
  503. border-radius: 50%;
  504. image {
  505. width: 100%;
  506. height: 100%;
  507. border-radius: 50%;
  508. }
  509. }
  510. .p-r {
  511. flex-direction: column;
  512. flex-grow: 1;
  513. max-width: calc(100% - 120rpx);
  514. display: flex;
  515. justify-content: space-between;
  516. .acea-row-item-bArea {
  517. width: 100%;
  518. display: flex;
  519. justify-content: space-between;
  520. .goodsname {
  521. flex-grow: 1;
  522. }
  523. .selde {
  524. width: 80rpx;
  525. }
  526. }
  527. }
  528. }
  529. .all-products-body {
  530. background: white;
  531. padding-left: 30px;
  532. .all-products-item {
  533. display: flex;
  534. margin-bottom: 20rpx;
  535. image {
  536. margin: auto;
  537. width: 128rpx;
  538. height: 128rpx;
  539. margin-right: 20rpx;
  540. border: 2rpx solid #FFFFFF;
  541. }
  542. .all-products-item-content {
  543. display: flex;
  544. flex-direction: column;
  545. width: calc(100% - 128rpx);
  546. .all-products-item-content-t {
  547. flex: 1;
  548. font-size: 24rpx;
  549. font-weight: 400;
  550. margin-right: 30rpx;
  551. color: #333333;
  552. line-height: 40rpx;
  553. }
  554. .all-products-item-content-b {
  555. flex: 1;
  556. font-size: 28rpx;
  557. font-weight: 500;
  558. line-height: 80rpx;
  559. display: flex;
  560. justify-content: space-between;
  561. image {
  562. margin: 0;
  563. width: 36rpx;
  564. height: 36rpx;
  565. }
  566. .red {
  567. display: block;
  568. font-size: 28rpx;
  569. font-weight: 500;
  570. color: #B22338 !important;
  571. margin-right: 10rpx;
  572. }
  573. .line-thr {
  574. display: block;
  575. font-size: 28rpx;
  576. font-weight: 400;
  577. color: #999999;
  578. text-decoration: line-through;
  579. }
  580. .count {
  581. font-size: 24rpx;
  582. font-weight: 400;
  583. color: #999999;
  584. margin-right: 30rpx;
  585. }
  586. }
  587. }
  588. }
  589. }
  590. .scroll-y{
  591. height: 600rpx;
  592. }
  593. .box_3 {
  594. background-color: rgba(250, 250, 250, 1);
  595. border-radius: 4px 4px 0px 0px;
  596. padding: 16rpx 16rpx 40rpx 16rpx;
  597. }
  598. .icon_2 {
  599. font-size: 32rpx;
  600. font-weight: 500;
  601. }
  602. .text_25 {
  603. overflow-wrap: break-word;
  604. color: rgba(17, 17, 17, 1);
  605. font-size: 32rpx;
  606. font-family: PingFangSC-Medium;
  607. font-weight: 500;
  608. text-align: left;
  609. white-space: nowrap;
  610. line-height: 44rpx;
  611. margin: 0 278rpx 0 264rpx;
  612. }
  613. .list_1 {
  614. height: 602rpx;
  615. margin: 24rpx 16rpx 0 0;
  616. }
  617. .list-items_1 {
  618. background-color: rgba(255, 255, 255, 1);
  619. border-radius: 4px;
  620. margin-bottom: 16rpx;
  621. padding: 24rpx 24rpx 24rpx 24rpx;
  622. }
  623. .group_14 {
  624. width: 638rpx;
  625. }
  626. .text_26 {
  627. overflow-wrap: break-word;
  628. color: rgba(17, 17, 17, 1);
  629. font-size: 28rpx;
  630. font-weight: NaN;
  631. text-align: left;
  632. white-space: nowrap;
  633. line-height: 40rpx;
  634. margin-right: 184rpx;
  635. }
  636. .text_27 {
  637. overflow-wrap: break-word;
  638. color: rgba(153, 153, 153, 1);
  639. font-size: 24rpx;
  640. font-weight: NaN;
  641. text-align: left;
  642. white-space: nowrap;
  643. line-height: 34rpx;
  644. margin-top: 16rpx;
  645. }
  646. .text-group_9 {
  647. overflow-wrap: break-word;
  648. color: rgba(102, 102, 102, 1);
  649. font-size: 20rpx;
  650. font-weight: NaN;
  651. text-align: left;
  652. white-space: nowrap;
  653. line-height: 36rpx;
  654. }
  655. .icon_3 {
  656. width: 34rpx;
  657. height: 34rpx;
  658. margin-left: 10rpx;
  659. /*margin: 4rpx 0 4rpx 4rpx;*/
  660. }
  661. .group_15 {
  662. margin: 8rpx 390rpx 0 0;
  663. }
  664. .tag_1 {
  665. background-color: rgba(255, 247, 248, 1);
  666. border-radius: 4px;
  667. padding: 8rpx 24rpx 8rpx 26rpx;
  668. }
  669. .text_28 {
  670. overflow-wrap: break-word;
  671. color: rgba(153, 153, 153, 1);
  672. font-size: 20rpx;
  673. font-weight: NaN;
  674. text-align: left;
  675. white-space: nowrap;
  676. line-height: 28rpx;
  677. }
  678. .image-view{
  679. width: 32rpx;
  680. height: 32rpx;
  681. .image{
  682. width: 28rpx;
  683. height: 28rpx;
  684. }
  685. }
  686. .dataGroup{
  687. margin-left: 20rpx;
  688. }
  689. </style>