group_cart.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <view :class="[AppTheme]" v-if="cache && data">
  3. <swiper class="carousel" :indicator-dots="true" :indicator-active-color="primary">
  4. <swiper-item v-for="(item, index) in appalbum" :key="index" class="carousel-item">
  5. <image @click="previewImage(index)" class="s-img" :src=" item" />
  6. </swiper-item>
  7. </swiper>
  8. <view class="title-text">
  9. <p>{{ cache.name }}</p>
  10. </view>
  11. <view class="title-text-cnent">
  12. <span class="text-neutral">
  13. 价格:¥ {{ cache.price }}
  14. <span class="money">¥{{ cache.oprice }}</span>
  15. </span>
  16. <span>单位: {{ cache.unit }}</span>
  17. <span>
  18. 已成团
  19. <span class="text-primary">{{ cache.sells }}</span>
  20. <span class="people text-primary">{{ cache.peoplenum }}</span>
  21. 人成团
  22. </span>
  23. </view>
  24. <view class="title-text-cnent" style="color: #999999;" v-if="cache.score<=0">本次活动不赠送积分</view>
  25. <view class="title-text-cnent" style="color: #999999;" v-else>本次活动赠送 {{cache.score}} 积分</view>
  26. <view class="tuan" v-show="grouplist">
  27. <view class="tuan-t">{{ data.groupCount }}人待成团</view>
  28. <view style="height: 1rpx;background-color: #e5e5e5;width: 100%;"></view>
  29. <view class="tuan-b" v-for="item in grouplist" :key="item.id">
  30. <image :src="item.headimgurl"></image>
  31. <view class="center">
  32. <p>{{ item.nickname }}</p>
  33. <p>
  34. 还差
  35. <span class="text-primary">{{item.left}}</span>
  36. 人,剩余
  37. <u-count-down :time="(item.rtime > timestamp ? item.rtime - timestamp : 0)*1000"
  38. format="DD:HH:mm:ss" autoStart millisecond :color="primary" font-size="28"
  39. @change="onChange">
  40. <view class="time">
  41. <text class="time__item">{{ timeData.days }}&nbsp;天</text>
  42. <text
  43. class="time__item">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}&nbsp;时</text>
  44. <text class="time__item">{{ timeData.minutes }}&nbsp;分</text>
  45. <text class="time__item">{{ timeData.seconds }}&nbsp;秒</text>
  46. </view>
  47. </u-count-down>
  48. </p>
  49. </view>
  50. <navigator :url="'./joinGroup?id=' + item.id" class="right border-primary text-primary">去参团</navigator>
  51. </view>
  52. </view>
  53. <view class="bottom_img">
  54. <p class="subtitle">商品详情</p>
  55. <view class="content-box">
  56. <!-- <rich-text :nodes="content"></rich-text> -->
  57. <u-parse :content="content" :lazy-load="true" :show-with-animation="true"></u-parse>
  58. </view>
  59. </view>
  60. <view class="bottom_but">
  61. <view @click="go1">
  62. <u-icon :color="primary" labelSize="12" color="#909399" label="首页" labelPos="bottom"
  63. labelColor="#909399" size="25" name="home-fill"></u-icon>
  64. </view>
  65. <view @click="fastbuy(0)">
  66. <span>¥{{cache.oprice}}</span>
  67. <span class="text">单独购买</span>
  68. </view>
  69. <view class="bg-linear-gradient" @click="fastbuy(1)">
  70. <span>¥{{cache.price}}</span>
  71. <span class="text">一键开团</span>
  72. </view>
  73. </view>
  74. <!-- #ifdef MP-WEIXIN -->
  75. <nologin ref="nologin" v-on:loginback="loginback"></nologin>
  76. <!-- #endif -->
  77. <!-- 站位 -->
  78. <view style="height: 150rpx;"></view>
  79. </view>
  80. </template>
  81. <script>
  82. import mall from '@/api/mall/index.js';
  83. import nologin from '@/components/nologin/nologin.vue';
  84. export default {
  85. components: {
  86. nologin
  87. },
  88. data() {
  89. return {
  90. primary: this.$theme.primary,
  91. data: '',
  92. appalbum: [],
  93. cache: [],
  94. grouplist: '',
  95. timestamp: '',
  96. settingFile: getApp().globalData.siteinfo,
  97. content: '',
  98. timeData: {},
  99. };
  100. },
  101. onLoad(options) {
  102. this.$bindid.getbindid(options, this.$store);
  103. this.timestamp = Date.parse(new Date()) / 1000;
  104. if (options && options.id) {
  105. this.actgoods(options.id);
  106. }
  107. },
  108. onShow() {
  109. },
  110. methods: {
  111. loginback() {
  112. //登录回调
  113. },
  114. previewImage(index) { //预览商品详情轮播图片
  115. uni.previewImage({
  116. current: index,
  117. urls: this.appalbum,
  118. indicator: 'number'
  119. })
  120. },
  121. go1() {
  122. uni.switchTab({
  123. url: '/pages/mall/mall'
  124. })
  125. },
  126. go() {
  127. uni.navigateTo({
  128. url: '../order/createOrder'
  129. });
  130. },
  131. onChange(e) {
  132. this.timeData = e
  133. },
  134. fastbuy(flag) {
  135. let that = this;
  136. // #ifdef MP-WEIXIN
  137. if (that.$store.state.islogin()) {
  138. that.fastbuy2(flag)
  139. } else {
  140. that.$refs.nologin.open();
  141. }
  142. // #endif
  143. // #ifdef H5 || APP-PLUS
  144. that.fastbuy2(flag)
  145. // #endif
  146. },
  147. fastbuy2(flag) {
  148. // //订阅模板消息
  149. let that = this
  150. let tmplIdsone = that.$config.temlist;
  151. if (tmplIdsone) {
  152. that.$until.requestSubscribeMessage([tmplIdsone['noticeSuccess']], tmplIdsone, function() {
  153. that.callback(flag)
  154. });
  155. } else {
  156. that.callback(flag)
  157. }
  158. },
  159. callback(flag) {
  160. var dt, orderurl;
  161. if (flag == 1) {
  162. dt = {
  163. sid: 0,
  164. goodsid: this.cache.id,
  165. vipid: uni.getStorageSync('userInfo').id,
  166. num: 1,
  167. isact: 1,
  168. groupid: 0,
  169. goodstype: this.cache.type
  170. };
  171. orderurl = {
  172. goodstype: this.cache.type,
  173. sid: 0,
  174. lasturl: this.data.lasturl,
  175. isact: 1,
  176. goodsid: this.data.cache.id
  177. }
  178. } else {
  179. dt = {
  180. sid: 0,
  181. goodsid: this.cache.id,
  182. goodstype: this.cache.type,
  183. vipid: uni.getStorageSync('userInfo').id,
  184. num: 1,
  185. goodstype: this.cache.type
  186. };
  187. orderurl = {
  188. sid: 0,
  189. goodstype: this.cache.type,
  190. lasturl: this.data.lasturl,
  191. goodsid: this.data.cache.id
  192. }
  193. }
  194. mall.fastbuys(dt).then(res => {
  195. if (res.status == 200) {
  196. uni.showToast({
  197. icon: 'loading',
  198. title: '生成订单',
  199. duration: 2000
  200. });
  201. setTimeout(() => {
  202. this.$u.route('/pagesD/pages/order/createOrder', orderurl);
  203. }, 2000);
  204. } else {
  205. this.$api.msg(res.msg);
  206. }
  207. });
  208. },
  209. actgoods(id) {
  210. mall.actgoods({
  211. id: id
  212. }).then(res => {
  213. if (res.status == 200) {
  214. this.data = res.data
  215. this.appalbum = res.data.appalbum;
  216. this.cache = res.data.cache;
  217. // 这里有问题
  218. this.grouplist = res.data.grouplist;
  219. /* 处理富文本*/
  220. this.content = this.cache.content.replace(/\<img src="/gi,
  221. `<img style='width:100%;display:block' src="${this.settingFile.root_rich_img}`);
  222. } else {
  223. this.$api.msg(res.msg);
  224. }
  225. });
  226. },
  227. }
  228. };
  229. </script>
  230. <style lang="scss">
  231. page {
  232. background: #f5f5f5;
  233. }
  234. .carousel {
  235. height: 375rpx * 2;
  236. }
  237. .carousel-item {
  238. width: 100%;
  239. .s-img {
  240. width: 100%;
  241. height: 100%;
  242. }
  243. .swiper-dots {
  244. left: 45rpx;
  245. bottom: 40rpx;
  246. }
  247. }
  248. .title-text {
  249. padding: 20rpx 30rpx;
  250. box-sizing: border-box;
  251. min-height: 90rpx;
  252. line-height: 45rpx;
  253. width: 97%;
  254. margin: 10rpx auto;
  255. background-color: #fff;
  256. p:nth-child(1) {
  257. font-size: 30rpx;
  258. }
  259. p:nth-child(2) {
  260. font-size: 32rpx;
  261. color: red;
  262. span {
  263. text-decoration: line-through;
  264. margin: 0 20rpx;
  265. font-size: 24rpx;
  266. color: #999999;
  267. }
  268. }
  269. }
  270. .title-text-cnent {
  271. padding: 30rpx;
  272. box-sizing: border-box;
  273. height: 90rpx;
  274. width: 97%;
  275. margin: 10rpx auto;
  276. background-color: #fff;
  277. display: flex;
  278. justify-content: space-between;
  279. font-size: 24rpx;
  280. .money {
  281. color: #999999;
  282. margin-left: 15rpx;
  283. text-decoration: line-through;
  284. }
  285. .people {
  286. margin-left: 15rpx;
  287. }
  288. }
  289. .tuan {
  290. padding: 30rpx;
  291. box-sizing: border-box;
  292. width: 97%;
  293. margin: 10rpx auto;
  294. background-color: #fff;
  295. font-size: 24rpx;
  296. .tuan-t {
  297. padding: 10rpx;
  298. box-sizing: border-box;
  299. font-size: 28rpx;
  300. margin-bottom: 10rpx;
  301. }
  302. .tuan-b {
  303. margin-top: 20rpx;
  304. box-sizing: border-box;
  305. width: 100%;
  306. display: flex;
  307. align-items: center;
  308. image {
  309. width: 110rpx;
  310. height: 110rpx;
  311. border-radius: 100%;
  312. }
  313. .center {
  314. width: 400rpx;
  315. p {
  316. padding: 0 20rpx;
  317. height: 40rpx;
  318. font-size: 30rpx;
  319. line-height: 40rpx;
  320. &:nth-child(2) {
  321. color: #999999;
  322. font-size: 26rpx;
  323. }
  324. }
  325. }
  326. .right {
  327. width: 64rpx * 2;
  328. height: 25rpx * 2;
  329. margin-left: 15rpx;
  330. border-width: 1rpx;
  331. border-style: solid;
  332. border-radius: 10rpx;
  333. text-align: center;
  334. line-height: 25rpx * 2;
  335. margin-top: 10rpx;
  336. }
  337. }
  338. }
  339. .detriment {
  340. position: fixed;
  341. bottom: 0;
  342. left: 0;
  343. width: 100%;
  344. }
  345. .bottom_img {
  346. width: 97%;
  347. margin: 10rpx auto;
  348. background-color: #fff;
  349. padding-bottom: 20rpx;
  350. padding: 0 15rpx;
  351. .content-box {
  352. padding-bottom: 50rpx;
  353. line-height: 41rpx;
  354. }
  355. }
  356. .subtitle {
  357. position: relative;
  358. font-size: 0.24rem;
  359. color: #999999;
  360. height: 45px;
  361. line-height: 45px;
  362. text-align: center;
  363. font-size: 14px;
  364. &:before {
  365. content: '';
  366. position: absolute;
  367. width: 10%;
  368. height: 1px;
  369. top: 50%;
  370. background-color: #999999;
  371. left: 25%;
  372. }
  373. &:after {
  374. content: '';
  375. position: absolute;
  376. width: 10%;
  377. height: 1px;
  378. top: 50%;
  379. background-color: #999999;
  380. right: 25%;
  381. }
  382. }
  383. .bottom_but {
  384. position: fixed;
  385. bottom: 0;
  386. left: 0;
  387. width: 100%;
  388. height: 100rpx;
  389. background-color: red;
  390. display: flex;
  391. .home {
  392. margin-top: -20rpx;
  393. }
  394. .icon {
  395. margin-top: -18rpx;
  396. }
  397. .text {
  398. margin-top: -35rpx;
  399. }
  400. view {
  401. font-size: 24rpx;
  402. background-color: #fff;
  403. display: flex;
  404. justify-content: space-around;
  405. align-items: center;
  406. flex-direction: column;
  407. }
  408. view:nth-child(1) {
  409. width: 200rpx;
  410. }
  411. view:nth-child(2) {
  412. flex: 1;
  413. color: #ffffff;
  414. background-color: #fa436a;
  415. font-size: 28rpx;
  416. }
  417. view:nth-child(3) {
  418. flex: 1;
  419. color: #ffffff;
  420. font-size: 28rpx;
  421. }
  422. }
  423. </style>