index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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 :value='ztd' placeholder-class='placeholder'
  45. maxlength="11"></input>
  46. </view>
  47. <u-picker @confirm="confirmZTD()" :show="showZTD" :columns="selfTakeList" keyName="name"></u-picker>
  48. </view>
  49. </view>
  50. <view class="list select-list" v-if="selectGoodList.length > 0">
  51. <view class="title">
  52. 团购商品
  53. </view>
  54. <view class="all-products-body" v-for="(itemn, indexn) in selectGoodList" :key="indexn">
  55. <view class="all-products-item">
  56. <image :src='itemn.goodsCover' v-if="itemn.goodsCover"></image>
  57. <image src="/static/images/sort-img.png" v-else></image>
  58. <view class="all-products-item-content">
  59. <view class="all-products-item-content-t">
  60. {{ itemn.goodsName }}
  61. </view>
  62. <view class="all-products-item-content-b">
  63. <view style="display:flex; flex-grow: 1;">
  64. <text class="red"> ¥{{ itemn.discountPrice }}</text>
  65. </view>
  66. <view @click="delItem(indexn)" class="count">
  67. <image
  68. src="http://www.gzzzyd.com/groupon/home_slices/错误@2x.png"
  69. mode="scaleToFill"
  70. />
  71. </view>
  72. <view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <button class="button_1 flex-col" @click="addGood">
  80. <text class="text_15">添加商品</text>
  81. </button>
  82. <button class='keepBnt' form-type="submit">保存并提交</button>
  83. <!-- #ifdef MP -->
  84. <!-- <view class="wechatAddress" v-if="!id" @click="getWxAddress">{{ $t(`导入微信地址`) }}</view> -->
  85. <!-- #endif -->
  86. <!-- #ifdef H5 -->
  87. <view class="wechatAddress" v-if="this.$wechat.isWeixin() && !id" @click="getAddress">{{ $t(`导入微信地址`) }}
  88. </view>
  89. <!-- #endif -->
  90. </view>
  91. </form>
  92. <!-- #ifdef MP -->
  93. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  94. <!-- #endif -->
  95. <!-- #ifndef MP -->
  96. <home></home>
  97. <!-- #endif -->
  98. <u-popup :show="addGoodPopupShow" @close="close" @open=" ">
  99. <view>
  100. <publish_good_list @getSelectData="getSelectData" v-if="addGoodPopupShow"></publish_good_list>
  101. </view>
  102. </u-popup>
  103. </view>
  104. </template>
  105. <script>
  106. import { publishGroupon, getAllSelfTake } from '@/api/groupon.js';
  107. import {
  108. toLogin
  109. } from '@/libs/login.js';
  110. import {
  111. mapGetters
  112. } from "vuex";
  113. // #ifdef MP
  114. import authorize from '@/components/Authorize';
  115. // #endif
  116. import home from '@/components/home';
  117. import publish_good_list from '../publish_good_list/index.vue';
  118. import colors from '@/mixins/color.js';
  119. export default {
  120. components: {
  121. // #ifdef MP
  122. authorize,
  123. // #endif
  124. home,
  125. publish_good_list
  126. },
  127. mixins: [colors],
  128. data () {
  129. return {
  130. grouponDateTime: '',
  131. takeDateTime: '',
  132. datetimerange1: '',
  133. datetimerange2: '',
  134. grouponReqData: {
  135. mainTitle: '',
  136. subTitle: '',
  137. grouponStartTime: '',
  138. grouponEndTime: '',
  139. takeStartTime: '',
  140. takeEndTime: '',
  141. selfTakeIds: [],
  142. goodsIds: []
  143. },
  144. grouponTimeRange: [],
  145. takeTimeRange: [],
  146. array: [],
  147. show1: false,
  148. show2: false,
  149. showZTD: false,
  150. addGoodPopupShow: false,
  151. id: 0, //地址id
  152. district: [],
  153. multiArray: [],
  154. multiIndex: [0, 0, 0],
  155. cityId: 0,
  156. news: '',
  157. noCoupon: 0,
  158. selectGoodList: [],
  159. selfTakeList: [],
  160. ztd: ''
  161. };
  162. },
  163. computed: mapGetters(['isLogin']),
  164. watch: {
  165. isLogin: {
  166. handler: function (newV, oldV) {
  167. if (newV) {
  168. this.getUserAddress();
  169. }
  170. },
  171. deep: true
  172. }
  173. },
  174. onLoad (options) {
  175. if (this.isLogin) {
  176. this.id = options.id || 0;
  177. uni.setNavigationBarTitle({
  178. title: '发布团购'
  179. })
  180. // this.getUserAddress();
  181. // this.getCityList();
  182. } else {
  183. toLogin();
  184. }
  185. },
  186. methods: {
  187. confirmDate1 (value) {
  188. let start = value[0];
  189. let end = value[1];
  190. this.grouponReqData.grouponStartTime = start;
  191. this.grouponReqData.grouponEndTime = end;
  192. this.grouponDateTime = start.substr(5, 2) + "/" + start.substr(8, 2) + " " + start.substr(11, 5) + " 至 "
  193. + end.substr(5, 2) + "/" + end.substr(8, 2) + " " + end.substr(11, 5);
  194. },
  195. confirmDate2 (value) {
  196. let start = value[0];
  197. let end = value[1];
  198. this.grouponReqData.takeStartTime = start;
  199. this.grouponReqData.takeEndTime = end;
  200. this.takeDateTime = start.substr(5, 2) + "/" + start.substr(8, 2) + " " + start.substr(11, 5) + " 至 "
  201. + end.substr(5, 2) + "/" + end.substr(8, 2) + " " + end.substr(11, 5);
  202. },
  203. selectDatetime () {
  204. this.$refs.mySon.show();
  205. },
  206. openSelfTakeTable () {
  207. getAllSelfTake({
  208. current: 1,
  209. size: 50
  210. }).then(res => {
  211. console.log(res.data);
  212. this.selfTakeList.push(res.data.records);
  213. console.log(this.selfTakeList);
  214. this.showZTD = true;
  215. })
  216. },
  217. delItem (index) {
  218. this.selectGoodList.splice(index, 1)
  219. },
  220. getSelectData (data) {
  221. console.log("getSelectData ", data)
  222. this.selectGoodList = data
  223. console.log(this.selectGoodList);
  224. },
  225. open () {
  226. // console.log('open');
  227. },
  228. close () {
  229. this.addGoodPopupShow = false
  230. // console.log('close');
  231. },
  232. addGood () {
  233. this.addGoodPopupShow = true
  234. },
  235. bindPickerChange: function (e) {
  236. this.index = e.detail.value;
  237. },
  238. dateConfirm (value) {
  239. console.log('dateConfirm! ', value)
  240. this.userAddress.date = value.value
  241. this.show1 = false
  242. },
  243. dateConfirmDate2 (value) {
  244. this.userAddress.date2 = value.value
  245. this.show2 = false
  246. },
  247. confirmZTD (value) {
  248. console.log(value)
  249. this.ztd = value.value[0].name;
  250. this.grouponReqData.selfTakeIds.push(value.value[0].id)
  251. this.showZTD = false
  252. },
  253. // #ifdef APP-PLUS
  254. // 获取选择的地区
  255. handleGetRegion (region) {
  256. this.region = region
  257. },
  258. // #endif
  259. onConfirm (val) {
  260. this.region = val.checkArr[0] + '-' + val.checkArr[1] + '-' + val.checkArr[2];
  261. },
  262. /**
  263. * 发布团购
  264. */
  265. formSubmit: function (e) {
  266. let that = this,
  267. value = e.detail.value;
  268. if (!value.mainTitle.trim()) {
  269. return that.$util.Tips({
  270. title: that.$t(`请填写主标题`)
  271. });
  272. }
  273. that.grouponReqData.mainTitle = value.mainTitle;
  274. if (!value.subTitle.trim()) {
  275. return that.$util.Tips({
  276. title: that.$t(`请填写副标题`)
  277. });
  278. }
  279. that.grouponReqData.subTitle = value.subTitle;
  280. if (!that.grouponReqData.grouponStartTime.trim() || !that.grouponReqData.grouponEndTime.trim()) {
  281. return that.$util.Tips({
  282. title: that.$t(`请选择团购时间`)
  283. });
  284. }
  285. if (!that.grouponReqData.takeStartTime.trim() || !that.grouponReqData.takeEndTime.trim()) {
  286. return that.$util.Tips({
  287. title: that.$t(`请选择取货时间`)
  288. });
  289. }
  290. if (that.grouponReqData.selfTakeIds.length < 1) {
  291. return that.$util.Tips({
  292. title: that.$t(`请选择自提点`)
  293. });
  294. }
  295. if (this.selectGoodList.length < 1) {
  296. return that.$util.Tips({
  297. title: that.$t(`请添加商品`)
  298. });
  299. }
  300. let goodsIds = [];
  301. this.selectGoodList.forEach(e => {
  302. goodsIds.push(e.id);
  303. that.grouponReqData.goodsIds = goodsIds;
  304. })
  305. uni.showLoading({
  306. title: that.$t(`发布中`),
  307. mask: true
  308. })
  309. let resSuccess = false;
  310. publishGroupon(that.grouponReqData).then(res => {
  311. that.$util.Tips({
  312. title: that.$t(`提交成功`),
  313. icon: 'success'
  314. });
  315. resSuccess = true
  316. }).catch(err => {
  317. return that.$util.Tips({
  318. title: err
  319. });
  320. })
  321. },
  322. }
  323. }
  324. </script>
  325. <style scoped lang="scss">
  326. .fontcolor {
  327. color: var(--view-theme);
  328. }
  329. .addAddress .list {
  330. background-color: #fff;
  331. padding-top: 10rpx;
  332. .title {
  333. margin: 30rpx;
  334. height: 44rpx;
  335. font-size: 32rpx;
  336. font-weight: bolder;
  337. color: #111111;
  338. line-height: 44rpx;
  339. }
  340. }
  341. .addAddress .list .item {
  342. padding: 30rpx;
  343. border-top: 1rpx solid #eee;
  344. }
  345. .addAddress .list .item .name {
  346. width: 195rpx;
  347. font-size: 30rpx;
  348. color: #333;
  349. }
  350. .addAddress .list .item .address {
  351. // width: 412rpx;
  352. flex: 1;
  353. margin-left: 20rpx;
  354. }
  355. .addAddress .list .item input {
  356. width: 475rpx;
  357. font-size: 30rpx;
  358. }
  359. .addAddress .list .item .placeholder {
  360. color: #ccc;
  361. }
  362. .addAddress .list .item picker {
  363. width: 475rpx;
  364. }
  365. .addAddress .list .item picker .picker {
  366. width: 410rpx;
  367. font-size: 30rpx;
  368. }
  369. .addAddress .list .item picker .iconfont {
  370. font-size: 43rpx;
  371. }
  372. .addAddress .default {
  373. padding: 0 30rpx;
  374. height: 90rpx;
  375. background-color: #fff;
  376. margin-top: 23rpx;
  377. }
  378. .addAddress .default checkbox {
  379. margin-right: 15rpx;
  380. }
  381. .addAddress .keepBnt {
  382. width: 90%;
  383. height: 84rpx;
  384. background: #B42A3E;
  385. border-radius: 8rpx;
  386. margin: 30rpx auto;
  387. font-size: 28rpx;
  388. font-weight: 400;
  389. color: #FFFFFF;
  390. line-height: 84rpx;
  391. }
  392. .addAddress .wechatAddress {
  393. width: 690rpx;
  394. height: 86rpx;
  395. border-radius: 50rpx;
  396. text-align: center;
  397. line-height: 86rpx;
  398. margin: 0 auto;
  399. font-size: 32rpx;
  400. color: var(--view-theme);
  401. border: 1px solid var(--view-theme);
  402. }
  403. .button_1 {
  404. width: 90%;
  405. height: 84rpx;
  406. background: #FFFFFF;
  407. border-radius: 8rpx;
  408. border: 2rpx solid #B42A3E;
  409. margin: 30rpx auto;
  410. font-size: 28rpx;
  411. font-weight: 400;
  412. color: #B42A3E;
  413. line-height: 84rpx;
  414. }
  415. .text_15 {
  416. overflow-wrap: break-word;
  417. color: rgba(180, 42, 62, 1);
  418. font-size: 14px;
  419. font-weight: NaN;
  420. text-align: center;
  421. white-space: nowrap;
  422. line-height: 20px;
  423. }
  424. .acea-row-item {
  425. display: flex;
  426. width: 100% !important;
  427. flex-direction: row;
  428. .picture {
  429. width: 120rpx;
  430. height: 120rpx;
  431. border-radius: 50%;
  432. image {
  433. width: 100%;
  434. height: 100%;
  435. border-radius: 50%;
  436. }
  437. }
  438. .p-r {
  439. flex-direction: column;
  440. flex-grow: 1;
  441. max-width: calc(100% - 120rpx);
  442. display: flex;
  443. justify-content: space-between;
  444. .acea-row-item-bArea {
  445. width: 100%;
  446. display: flex;
  447. justify-content: space-between;
  448. .goodsname {
  449. flex-grow: 1;
  450. }
  451. .selde {
  452. width: 80rpx;
  453. }
  454. }
  455. }
  456. }
  457. .all-products-body {
  458. background: white;
  459. padding-left: 30px;
  460. .all-products-item {
  461. display: flex;
  462. margin-bottom: 20rpx;
  463. image {
  464. margin: auto;
  465. width: 128rpx;
  466. height: 128rpx;
  467. margin-right: 20rpx;
  468. border: 2rpx solid #FFFFFF;
  469. }
  470. .all-products-item-content {
  471. display: flex;
  472. flex-direction: column;
  473. width: calc(100% - 128rpx);
  474. .all-products-item-content-t {
  475. flex: 1;
  476. font-size: 24rpx;
  477. font-weight: 400;
  478. margin-right: 30rpx;
  479. color: #333333;
  480. line-height: 40rpx;
  481. }
  482. .all-products-item-content-b {
  483. flex: 1;
  484. font-size: 28rpx;
  485. font-weight: 500;
  486. line-height: 80rpx;
  487. display: flex;
  488. justify-content: space-between;
  489. image {
  490. margin: 0;
  491. width: 36rpx;
  492. height: 36rpx;
  493. }
  494. .red {
  495. display: block;
  496. font-size: 28rpx;
  497. font-weight: 500;
  498. color: #B22338 !important;
  499. margin-right: 10rpx;
  500. }
  501. .line-thr {
  502. display: block;
  503. font-size: 28rpx;
  504. font-weight: 400;
  505. color: #999999;
  506. text-decoration: line-through;
  507. }
  508. .count {
  509. font-size: 24rpx;
  510. font-weight: 400;
  511. color: #999999;
  512. margin-right: 30rpx;
  513. }
  514. }
  515. }
  516. }
  517. }
  518. </style>