index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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 placeholder='请选择提自提点' name="phone" disabled v-model="ztd" :value='ztd' placeholder-class='placeholder'
  45. maxlength="11"></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" @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 @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. console.log(this.grouponReqData.selfTakeIds)
  232. this.selfTakeList.forEach(e =>{
  233. this.grouponReqData.selfTakeIds.forEach(ee =>{
  234. if (e.id === ee){
  235. if (this.ztd){
  236. this.ztd=this.ztd +','+e.name
  237. }else {
  238. this.ztd=e.name
  239. }
  240. }
  241. })
  242. })
  243. console.log(this.ztd)
  244. },
  245. clickSelfTake(item,index){
  246. item.addressTrue = !item.addressTrue;
  247. this.$set(this.selfTakeList,index,item)
  248. if (this.grouponReqData.selfTakeIds.indexOf(item.id) === -1){
  249. this.grouponReqData.selfTakeIds.push(item.id)
  250. }else {
  251. this.grouponReqData.selfTakeIds = this.grouponReqData.selfTakeIds.filter(iter => iter !== item.id)
  252. }
  253. },
  254. confirmDate1 (value) {
  255. let start = value[0];
  256. let end = value[1];
  257. this.grouponReqData.grouponStartTime = start;
  258. this.grouponReqData.grouponEndTime = end;
  259. this.grouponDateTime = start.substr(5, 2) + "/" + start.substr(8, 2) + " " + start.substr(11, 5) + " 至 "
  260. + end.substr(5, 2) + "/" + end.substr(8, 2) + " " + end.substr(11, 5);
  261. },
  262. confirmDate2 (value) {
  263. let start = value[0];
  264. let end = value[1];
  265. this.grouponReqData.takeStartTime = start;
  266. this.grouponReqData.takeEndTime = end;
  267. this.takeDateTime = start.substr(5, 2) + "/" + start.substr(8, 2) + " " + start.substr(11, 5) + " 至 "
  268. + end.substr(5, 2) + "/" + end.substr(8, 2) + " " + end.substr(11, 5);
  269. },
  270. selectDatetime () {
  271. this.$refs.mySon.show();
  272. },
  273. openSelfTakeTable () {
  274. getAllSelfTake({
  275. current: 1,
  276. size: 50
  277. }).then(res => {
  278. this.selfTakeShow = true;
  279. console.log(res.data);
  280. this.selfTakeList=res.data.records;
  281. console.log(this.selfTakeList);
  282. })
  283. },
  284. delItem (index) {
  285. this.selectGoodList.splice(index, 1)
  286. },
  287. getSelectData (data) {
  288. console.log("getSelectData ", data)
  289. this.selectGoodList = data
  290. console.log(this.selectGoodList);
  291. },
  292. open () {
  293. // console.log('open');
  294. },
  295. close () {
  296. this.addGoodPopupShow = false
  297. // console.log('close');
  298. },
  299. addGood () {
  300. this.addGoodPopupShow = true
  301. },
  302. bindPickerChange: function (e) {
  303. this.index = e.detail.value;
  304. },
  305. dateConfirm (value) {
  306. console.log('dateConfirm! ', value)
  307. this.userAddress.date = value.value
  308. this.show1 = false
  309. },
  310. dateConfirmDate2 (value) {
  311. this.userAddress.date2 = value.value
  312. this.show2 = false
  313. },
  314. confirmZTD (value) {
  315. console.log(value)
  316. this.ztd = value.value[0].name;
  317. this.grouponReqData.selfTakeIds.push(value.value[0].id)
  318. this.showZTD = false
  319. },
  320. // #ifdef APP-PLUS
  321. // 获取选择的地区
  322. handleGetRegion (region) {
  323. this.region = region
  324. },
  325. // #endif
  326. onConfirm (val) {
  327. this.region = val.checkArr[0] + '-' + val.checkArr[1] + '-' + val.checkArr[2];
  328. },
  329. /**
  330. * 发布团购
  331. */
  332. formSubmit: function (e) {
  333. let that = this,
  334. value = e.detail.value;
  335. if (!value.mainTitle.trim()) {
  336. return that.$util.Tips({
  337. title: that.$t(`请填写主标题`)
  338. });
  339. }
  340. that.grouponReqData.mainTitle = value.mainTitle;
  341. if (!value.subTitle.trim()) {
  342. return that.$util.Tips({
  343. title: that.$t(`请填写副标题`)
  344. });
  345. }
  346. that.grouponReqData.subTitle = value.subTitle;
  347. if (!that.grouponReqData.grouponStartTime.trim() || !that.grouponReqData.grouponEndTime.trim()) {
  348. return that.$util.Tips({
  349. title: that.$t(`请选择团购时间`)
  350. });
  351. }
  352. if (!that.grouponReqData.takeStartTime.trim() || !that.grouponReqData.takeEndTime.trim()) {
  353. return that.$util.Tips({
  354. title: that.$t(`请选择取货时间`)
  355. });
  356. }
  357. if (that.grouponReqData.selfTakeIds.length < 1) {
  358. return that.$util.Tips({
  359. title: that.$t(`请选择自提点`)
  360. });
  361. }
  362. if (this.selectGoodList.length < 1) {
  363. return that.$util.Tips({
  364. title: that.$t(`请添加商品`)
  365. });
  366. }
  367. let goodsIds = [];
  368. this.selectGoodList.forEach(e => {
  369. goodsIds.push(e.id);
  370. that.grouponReqData.goodsIds = goodsIds;
  371. })
  372. uni.showLoading({
  373. title: that.$t(`发布中`),
  374. mask: true
  375. })
  376. let resSuccess = false;
  377. publishGroupon(that.grouponReqData).then(res => {
  378. that.$util.Tips({
  379. title: that.$t(`提交成功`),
  380. icon: 'success'
  381. });
  382. resSuccess = true
  383. }).catch(err => {
  384. return that.$util.Tips({
  385. title: err
  386. });
  387. })
  388. },
  389. }
  390. }
  391. </script>
  392. <style scoped lang="scss">
  393. @import "/static/css/common.css";
  394. .fontcolor {
  395. color: var(--view-theme);
  396. }
  397. .addAddress .list {
  398. background-color: #fff;
  399. padding-top: 10rpx;
  400. .title {
  401. margin: 30rpx;
  402. height: 44rpx;
  403. font-size: 32rpx;
  404. font-weight: bolder;
  405. color: #111111;
  406. line-height: 44rpx;
  407. }
  408. }
  409. .addAddress .list .item {
  410. padding: 30rpx;
  411. border-top: 1rpx solid #eee;
  412. }
  413. .addAddress .list .item .name {
  414. width: 195rpx;
  415. font-size: 30rpx;
  416. color: #333;
  417. }
  418. .addAddress .list .item .address {
  419. // width: 412rpx;
  420. flex: 1;
  421. margin-left: 20rpx;
  422. }
  423. .addAddress .list .item input {
  424. width: 475rpx;
  425. font-size: 30rpx;
  426. }
  427. .addAddress .list .item .placeholder {
  428. color: #ccc;
  429. }
  430. .addAddress .list .item picker {
  431. width: 475rpx;
  432. }
  433. .addAddress .list .item picker .picker {
  434. width: 410rpx;
  435. font-size: 30rpx;
  436. }
  437. .addAddress .list .item picker .iconfont {
  438. font-size: 43rpx;
  439. }
  440. .addAddress .default {
  441. padding: 0 30rpx;
  442. height: 90rpx;
  443. background-color: #fff;
  444. margin-top: 23rpx;
  445. }
  446. .addAddress .default checkbox {
  447. margin-right: 15rpx;
  448. }
  449. .addAddress .keepBnt {
  450. width: 90%;
  451. height: 84rpx;
  452. background: #B42A3E;
  453. border-radius: 8rpx;
  454. margin: 30rpx auto;
  455. font-size: 28rpx;
  456. font-weight: 400;
  457. color: #FFFFFF;
  458. line-height: 84rpx;
  459. }
  460. .addAddress .wechatAddress {
  461. width: 690rpx;
  462. height: 86rpx;
  463. border-radius: 50rpx;
  464. text-align: center;
  465. line-height: 86rpx;
  466. margin: 0 auto;
  467. font-size: 32rpx;
  468. color: var(--view-theme);
  469. border: 1px solid var(--view-theme);
  470. }
  471. .button_1 {
  472. width: 90%;
  473. height: 84rpx;
  474. background: #FFFFFF;
  475. border-radius: 8rpx;
  476. border: 2rpx solid #B42A3E;
  477. margin: 30rpx auto;
  478. font-size: 28rpx;
  479. font-weight: 400;
  480. color: #B42A3E;
  481. line-height: 84rpx;
  482. }
  483. .text_15 {
  484. overflow-wrap: break-word;
  485. color: rgba(180, 42, 62, 1);
  486. font-size: 14px;
  487. font-weight: NaN;
  488. text-align: center;
  489. white-space: nowrap;
  490. line-height: 20px;
  491. }
  492. .acea-row-item {
  493. display: flex;
  494. width: 100% !important;
  495. flex-direction: row;
  496. .picture {
  497. width: 120rpx;
  498. height: 120rpx;
  499. border-radius: 50%;
  500. image {
  501. width: 100%;
  502. height: 100%;
  503. border-radius: 50%;
  504. }
  505. }
  506. .p-r {
  507. flex-direction: column;
  508. flex-grow: 1;
  509. max-width: calc(100% - 120rpx);
  510. display: flex;
  511. justify-content: space-between;
  512. .acea-row-item-bArea {
  513. width: 100%;
  514. display: flex;
  515. justify-content: space-between;
  516. .goodsname {
  517. flex-grow: 1;
  518. }
  519. .selde {
  520. width: 80rpx;
  521. }
  522. }
  523. }
  524. }
  525. .all-products-body {
  526. background: white;
  527. padding-left: 30px;
  528. .all-products-item {
  529. display: flex;
  530. margin-bottom: 20rpx;
  531. image {
  532. margin: auto;
  533. width: 128rpx;
  534. height: 128rpx;
  535. margin-right: 20rpx;
  536. border: 2rpx solid #FFFFFF;
  537. }
  538. .all-products-item-content {
  539. display: flex;
  540. flex-direction: column;
  541. width: calc(100% - 128rpx);
  542. .all-products-item-content-t {
  543. flex: 1;
  544. font-size: 24rpx;
  545. font-weight: 400;
  546. margin-right: 30rpx;
  547. color: #333333;
  548. line-height: 40rpx;
  549. }
  550. .all-products-item-content-b {
  551. flex: 1;
  552. font-size: 28rpx;
  553. font-weight: 500;
  554. line-height: 80rpx;
  555. display: flex;
  556. justify-content: space-between;
  557. image {
  558. margin: 0;
  559. width: 36rpx;
  560. height: 36rpx;
  561. }
  562. .red {
  563. display: block;
  564. font-size: 28rpx;
  565. font-weight: 500;
  566. color: #B22338 !important;
  567. margin-right: 10rpx;
  568. }
  569. .line-thr {
  570. display: block;
  571. font-size: 28rpx;
  572. font-weight: 400;
  573. color: #999999;
  574. text-decoration: line-through;
  575. }
  576. .count {
  577. font-size: 24rpx;
  578. font-weight: 400;
  579. color: #999999;
  580. margin-right: 30rpx;
  581. }
  582. }
  583. }
  584. }
  585. }
  586. .scroll-y{
  587. height: 600rpx;
  588. }
  589. .box_3 {
  590. background-color: rgba(250, 250, 250, 1);
  591. border-radius: 4px 4px 0px 0px;
  592. padding: 16rpx 16rpx 40rpx 16rpx;
  593. }
  594. .icon_2 {
  595. font-size: 32rpx;
  596. font-weight: 500;
  597. }
  598. .text_25 {
  599. overflow-wrap: break-word;
  600. color: rgba(17, 17, 17, 1);
  601. font-size: 32rpx;
  602. font-family: PingFangSC-Medium;
  603. font-weight: 500;
  604. text-align: left;
  605. white-space: nowrap;
  606. line-height: 44rpx;
  607. margin: 0 278rpx 0 264rpx;
  608. }
  609. .list_1 {
  610. height: 602rpx;
  611. margin: 24rpx 16rpx 0 0;
  612. }
  613. .list-items_1 {
  614. background-color: rgba(255, 255, 255, 1);
  615. border-radius: 4px;
  616. margin-bottom: 16rpx;
  617. padding: 24rpx 24rpx 24rpx 24rpx;
  618. }
  619. .group_14 {
  620. width: 638rpx;
  621. }
  622. .text_26 {
  623. overflow-wrap: break-word;
  624. color: rgba(17, 17, 17, 1);
  625. font-size: 28rpx;
  626. font-weight: NaN;
  627. text-align: left;
  628. white-space: nowrap;
  629. line-height: 40rpx;
  630. margin-right: 184rpx;
  631. }
  632. .text_27 {
  633. overflow-wrap: break-word;
  634. color: rgba(153, 153, 153, 1);
  635. font-size: 24rpx;
  636. font-weight: NaN;
  637. text-align: left;
  638. white-space: nowrap;
  639. line-height: 34rpx;
  640. margin-top: 16rpx;
  641. }
  642. .text-group_9 {
  643. overflow-wrap: break-word;
  644. color: rgba(102, 102, 102, 1);
  645. font-size: 20rpx;
  646. font-weight: NaN;
  647. text-align: left;
  648. white-space: nowrap;
  649. line-height: 36rpx;
  650. }
  651. .icon_3 {
  652. width: 34rpx;
  653. height: 34rpx;
  654. margin-left: 10rpx;
  655. /*margin: 4rpx 0 4rpx 4rpx;*/
  656. }
  657. .group_15 {
  658. margin: 8rpx 390rpx 0 0;
  659. }
  660. .tag_1 {
  661. background-color: rgba(255, 247, 248, 1);
  662. border-radius: 4px;
  663. padding: 8rpx 24rpx 8rpx 26rpx;
  664. }
  665. .text_28 {
  666. overflow-wrap: break-word;
  667. color: rgba(153, 153, 153, 1);
  668. font-size: 20rpx;
  669. font-weight: NaN;
  670. text-align: left;
  671. white-space: nowrap;
  672. line-height: 28rpx;
  673. }
  674. .image-view{
  675. width: 32rpx;
  676. height: 32rpx;
  677. .image{
  678. width: 28rpx;
  679. height: 28rpx;
  680. }
  681. }
  682. .dataGroup{
  683. margin-left: 20rpx;
  684. }
  685. </style>