p_details.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <view class="container">
  3. <!-- 轮播图 -->
  4. <swiper-banner imgScale="1:1" :imgArr="detail.goods_img" :duration="1000" :interval="5000" :circular="true" :autoplay="true" :indicator-dots="true" indicator-active-color="#12B280" indicator-color="rgba(255, 255, 255, .82)"></swiper-banner>
  5. <!-- 轮播图-end -->
  6. <!-- 价格信息栏 -->
  7. <view class="price_info flex_r flex_ac flex_jb">
  8. <view v-if="type == 5" class="price">
  9. <span v-if="Number(detail.cost_price) != 0">{{ detail.cost_price }}元</span>
  10. <span v-if="Number(detail.cha_bao) != 0 && Number(detail.cost_price) != 0">+</span>
  11. <span v-if="Number(detail.cha_bao) != 0">{{ detail.cha_bao }}茶宝</span>
  12. </view>
  13. <view v-else class="price" :class="type == 2 ? 'samll' : ''">
  14. <text class="p_favour" v-if="type == 1">¥{{ detail.total_amount }}</text>
  15. <text class="p_favour" v-if="type == 2">¥{{ detail.trade_price }} + {{detail.trade_num}}批发券 + {{detail.treasure_price}}茶宝</text>
  16. <text class="p_favour" v-if="type == 3">¥{{ detail.cost_price }}</text>
  17. <text class="p_favour" v-if="type == 4">¥{{ $h.Sub(detail.cost_price,detail.consume) }}</text>
  18. <text class="p_favour" v-if="type == 5">¥{{ detail.cost_price }} + {{ detail.treasure_price }}茶宝</text>
  19. <template v-if="type == 6">
  20. <text class="p_favour">¥{{ detail.cost_price }}</text>
  21. <text class="un_p_favour">¥{{ detail.original_price }}</text>
  22. </template>
  23. <!-- <text class="p_trade" v-if="type == 1">送 {{detail.trade_give_num}} 批发券</text> -->
  24. <text class="p_trade" v-if="(type == 3 || type == 4)">送 {{detail.give_cha_bao}} 茶宝</text>
  25. <view v-if="type == 4">
  26. <text class="un_p_favour un_p">{{ detail.cost_price }}</text>
  27. <text class="p_trade">消费金抵扣 {{detail.consume}}</text>
  28. </view>
  29. </view>
  30. <view class="price_span flex_r flex_ac flex_je">
  31. <view class="triangle"></view>
  32. <view class="span_conten flex_r flex_ac flex_jc">{{ tidyTpye(goodsDa.type) }}</view>
  33. </view>
  34. </view>
  35. <!-- 价格信息栏-end -->
  36. <!-- 标题信息栏 -->
  37. <view class="title_info">
  38. <view class="goods_name">{{ detail.goods_name }}</view>
  39. <view class="goods_teac flex_r flex_jb" v-if="['3','4'].includes(type)">
  40. <view class="product-txt">限时赠送{{ detail.teac }}TeaC</view>
  41. <view class="product-txt fenxiang">
  42. <text class="iconfont red">&#xe62b;</text>
  43. <text class="red">分享约获得 {{ detail.first_teac }} {{type==3?'TeaC':'现金'}}</text>
  44. </view>
  45. </view>
  46. <view class="goods_subName">{{ detail.goodsMsg }}</view>
  47. </view>
  48. <!-- 标题信息栏-end -->
  49. <!-- 产品简介 -->
  50. <view class="brief mar_t20">
  51. <view class="brief_title flex_r flex_ac">产品简介</view>
  52. <view class="brief_con">
  53. <mp-html :content="detail.goods_content" ref="jyf"></mp-html>
  54. <!-- <image :lazy-load="true" style="width: 100%;display: block;" v-for="(item,index) in detail.goodsDetailesImage" :key="index" :src="item" mode="widthFix"></image> -->
  55. </view>
  56. </view>
  57. <!-- 产品简介-end -->
  58. <!-- 底部导航组件 -->
  59. <view class="option">
  60. <uni-goods-nav :fill="true" :options="options" :buttonGroup="type == 5 ? buttonGroupTea : buttonGroup" @click="onClick" @buttonClick="buttonClick" />
  61. </view>
  62. <!-- 底部导航组件-end -->
  63. <!-- 授权 -->
  64. <authorize-module v-if="showAuth" :shopInfo="shopInfo" @authGetTelSuccess="onauthGetTelSuccess" />
  65. <!-- 授权-end -->
  66. <!-- 购买或加入购物车弹窗 -->
  67. <uni-popup ref="shopping" type="bottom">
  68. <view class="shopping">
  69. <view class="close_con flex_r flex_je">
  70. <view class="iconfont close_img" @tap="closeBtn">&#xe609;</view>
  71. </view>
  72. <view class="goods_info flex_r">
  73. <image class="goods_img" :src="detail.original_img" mode=""></image>
  74. <view class="goods_con flex_c flex_jb">
  75. <view class="shop_names">{{ detail.goods_name }}</view>
  76. <view class="goods_msg" v-if="type == 1">¥{{ detail.total_amount }}</view>
  77. <view class="goods_msg" v-else-if="type == 2">{{ detail.trade_price }}元+{{ detail.trade_num }}批发券+{{ detail.treasure_price }}茶宝</view>
  78. <view class="goods_msg" v-else>¥{{ detail.cost_price }}</view>
  79. <view class="num_con flex_r flex_je" v-if="type != 6">
  80. <uni-number-box :min="1" @change="bindChange" :value="buyNum"></uni-number-box>
  81. </view>
  82. <view class="num_str flex_r flex_je" v-else>x 1</view>
  83. </view>
  84. </view>
  85. <view class="goods_option flex_r flex_ac flex_jse" v-if="type == 1">
  86. <view class="goods_raido flex_r flex_ac" @tap="setWay('0')">
  87. <view class="raido_img" :class="pfway == '0' ? 'raido_box' : ''"></view>
  88. <view class="raido_text">零售产品邮寄</view>
  89. </view>
  90. <view class="goods_raido flex_r flex_ac" @tap="setWay('1')">
  91. <view class="raido_img" :class="pfway == '1' ? 'raido_box' : ''"></view>
  92. <view class="raido_text">零售产品置换</view>
  93. </view>
  94. </view>
  95. <checkbox-group class="flex_r flex_ac flex_jc" @change="checkboxChange">
  96. <label class="option_box">
  97. <checkbox value="1" :checked="checked" color="#2DB389" style="transform: scale(0.7)" />
  98. 我已阅读同意<text @tap.stop="getProPage" v-if="type != 5 && type != 6">《购买协议》</text>
  99. <text @tap.stop="getProPage" v-else-if="type == 5">《兑换协议》</text>
  100. <text @tap.stop="getProPage" v-else-if="type == 6">《天天捡漏协议》</text>
  101. </label>
  102. </checkbox-group>
  103. <view class="confim flex_r flex_ac flex_jc" @tap="ToPayPage">确定</view>
  104. </view>
  105. </uni-popup>
  106. <!-- 购买或加入购物车弹窗-end -->
  107. </view>
  108. </template>
  109. <script>
  110. let page = 1;
  111. let app = getApp();
  112. var appEv = app.$vm.$options;
  113. import { post } from "@/request/api.js";
  114. import mpHtml from "@/uni_modules/mp-html/components/mp-html/mp-html.vue"
  115. import swiperBanner from "@/components/swiperBanner/index.vue";
  116. import uniGoodsNav from "@/components/uni-goods-nav/uni-goods-nav.vue";
  117. import uniNumberBox from "@/components/uni-number-box/uni-number-box.vue";
  118. import authorizeModule from "@/components/authorize-module/index";
  119. export default {
  120. components: {
  121. mpHtml,
  122. uniGoodsNav,
  123. swiperBanner,
  124. uniNumberBox,
  125. authorizeModule,
  126. },
  127. data() {
  128. return {
  129. imgArr: ["/static/goods5.jpg"],
  130. content: "",
  131. options: [
  132. // 底部导航跳转
  133. {
  134. icon: "home",
  135. text: "主页",
  136. },
  137. // {
  138. // icon: 'cart',
  139. // text: '购物车',
  140. // info: 0
  141. // }
  142. ],
  143. buttonGroup: [
  144. // 底部操作按钮
  145. // {
  146. // text: '加入购物车',
  147. // backgroundColor: '#ff0000',
  148. // color: '#fff'
  149. // },
  150. {
  151. text: "立即购买",
  152. backgroundColor: "#ffa200",
  153. color: "#fff",
  154. },
  155. ],
  156. buttonGroupTea: [
  157. // 底部操作按钮
  158. // {
  159. // text: '加入购物车',
  160. // backgroundColor: '#ff0000',
  161. // color: '#fff'
  162. // },
  163. {
  164. text: "立即兑换",
  165. backgroundColor: "#ffa200",
  166. color: "#fff",
  167. },
  168. ],
  169. btnIndex: 0, // 用户点击按钮事件判断 0:加入购物车;1:立即购买
  170. type: null, // 商品类型,1零售 2批发 3精品 4今日值买
  171. goodsId: "", // 商品ID
  172. id: "", //合伙人套餐ID
  173. detail: {
  174. goods: {},
  175. }, // 商品详情
  176. checked: false, //是否选中协议
  177. buyNum: 1, //购买数量
  178. pfway: "1", // 批发
  179. qhway: "0", //提货方式
  180. shopInfo: {}, // 商铺信息
  181. // showAuth: false,
  182. userinfo: {},
  183. goodsDa: {},
  184. unid: "",
  185. };
  186. },
  187. onLoad: function(e) {
  188. this.userinfo = uni.getStorageSync("userinfo");
  189. let token = uni.getStorageSync("token");
  190. this.type = e.type;
  191. this.goodsDa = e;
  192. this.loadData(e);
  193. if (e.invite && !token) this.login(e.invite);
  194. },
  195. onShow: function() {},
  196. methods: {
  197. // 商品详情信息
  198. loadData(da) {
  199. post("v1/goods/goodsDetail", da).then((res) => {
  200. if (res.code === 0) {
  201. this.detail = res.data.data;
  202. let imgs = [];
  203. imgs.push(this.detail.original_img);
  204. imgs.push(...this.detail.goods_img);
  205. this.detail.goods_img = imgs;
  206. } else {
  207. uni.showModal({
  208. title: "提示",
  209. content: res.msg,
  210. showCancel: false,
  211. success: function(res) {
  212. if (res) {
  213. uni.navigateBack({
  214. delta: 1,
  215. });
  216. }
  217. },
  218. });
  219. }
  220. });
  221. },
  222. // 去购买
  223. ToPayPage: function() {
  224. if (!this.checked) {
  225. appEv.errTips("请阅读并同意购买协议");
  226. return;
  227. }
  228. if (this.btnIndex == 0) {
  229. this.toPayOrder();
  230. }
  231. },
  232. // 创建购买订单
  233. toPayOrder: function() {
  234. let da = {
  235. ...this.goodsDa,
  236. num: Number(this.buyNum),
  237. is_sell: ['1','2'].includes(this.type) ? this.pfway : "0",
  238. };
  239. this.goto("/pages/to-pay-list/index", da);
  240. },
  241. // 添加到购物车
  242. SetCartGoodsList() {},
  243. // 购买数量更改
  244. bindChange(e) {
  245. this.buyNum = e;
  246. },
  247. // 更改批发方式
  248. setWay(e) {
  249. this.pfway = e;
  250. },
  251. setQhWay(e) {
  252. this.qhway = e
  253. },
  254. // 点击同意协议
  255. checkboxChange(e) {
  256. let index = e.detail.value.indexOf("1");
  257. if (index != -1) {
  258. this.checked = true;
  259. } else {
  260. this.checked = false;
  261. }
  262. },
  263. // 点击底部主页购物车等按钮
  264. onClick(e) {
  265. if (e.index === 0) {
  266. uni.switchTab({ url: "/pages/index/index" });
  267. }
  268. },
  269. // 点击立即购买或加入购物车
  270. buttonClick: function(e) {
  271. this.btnIndex = e.index;
  272. this.$refs.shopping.open();
  273. },
  274. // 点击关闭弹窗
  275. closeBtn: function() {
  276. this.$refs.shopping.close();
  277. },
  278. getProPage() {
  279. uni.navigateTo({
  280. url: "/pages/pay-agreement/index?type=" + this.goodsDa.type,
  281. });
  282. },
  283. SoHAuth(){
  284. this.$refs.autho.onSoHAuth();
  285. },
  286. login(invite) {
  287. let that = this;
  288. // #ifdef MP-WEIXIN
  289. wx.login({
  290. success(res) {
  291. if (res.code) {
  292. post("v1/appletLogin", {
  293. invite,
  294. code: res.code,
  295. }).then((res) => {
  296. if (res.code === 0) {
  297. if (res.data.token) {
  298. uni.setStorageSync("token", res.data.token);
  299. that.getuserInfo();
  300. } else {
  301. that.unid = res.data.unid;
  302. that.shopInfo = app.globalData.shopInfo;
  303. that.SoHAuth(); //调取授权弹窗
  304. }
  305. }
  306. });
  307. }
  308. },
  309. });
  310. // #endif
  311. },
  312. onauthGetTelSuccess(da) {
  313. this.SoHAuth();
  314. post("v1/getMobile", {
  315. unid: this.unid,
  316. ...da.detail,
  317. }).then((res) => {
  318. if (res.code === 0) {
  319. uni.setStorageSync("token", res.data.token);
  320. this.getuserInfo();
  321. }
  322. });
  323. },
  324. async getuserInfo() {
  325. this.userinfo = await uni.userfun();
  326. },
  327. },
  328. onShareAppMessage: function() {
  329. let userinfo = uni.getStorageSync("userinfo");
  330. var path =
  331. "/pages/product/p_details?agentId=1" +
  332. "&id=" +
  333. this.goodsDa.id +
  334. "&type=" +
  335. this.goodsDa.type;
  336. if (userinfo.invite) {
  337. path =
  338. "/pages/product/p_details?invite=" +
  339. userinfo.invite +
  340. "&id=" +
  341. this.goodsDa.id +
  342. "&type=" +
  343. this.goodsDa.type;
  344. }
  345. var title = `让数字经济赋能美好生活!`;
  346. return {
  347. title: title,
  348. path: path,
  349. };
  350. },
  351. };
  352. </script>
  353. <style lang="scss">
  354. // 页面配置
  355. page {
  356. background: #f5f5f5;
  357. }
  358. .container {
  359. padding-bottom: 90rpx;
  360. }
  361. // 页面配置-end
  362. // 价格信息栏
  363. .price_span {
  364. width: 283rpx;
  365. height: 100%;
  366. position: relative;
  367. }
  368. .price text {
  369. // font-size: 24rpx;
  370. color: #fff;
  371. font-family: "SourceHanSansCN-Medium";
  372. }
  373. .price_info {
  374. background: #ff6d44;
  375. height: 92rpx;
  376. width: 100%;
  377. box-sizing: border-box;
  378. }
  379. .price {
  380. color: #fff;
  381. margin-left: 20rpx;
  382. width: 400rpx;
  383. .p_favour {
  384. font-size: 36rpx;
  385. }
  386. .un_p_favour {
  387. font-size: 26rpx;
  388. text-decoration: line-through;
  389. margin-left: 16rpx;
  390. &.un_p{
  391. margin-left: 0;
  392. }
  393. }
  394. .p_trade {
  395. font-size: 20rpx;
  396. margin-left: 20rpx;
  397. }
  398. }
  399. .span_conten {
  400. width: calc(283rpx - 46rpx);
  401. height: 100%;
  402. background: #ffcabb;
  403. position: relative;
  404. font-size: 34rpx;
  405. font-family: "SourceHanSansCN-Medium";
  406. color: #682918;
  407. }
  408. .triangle {
  409. width: 0px;
  410. height: 0px;
  411. border-top: 92rpx solid rgba(0, 0, 0, 0);
  412. border-right: 92rpx solid rgba(0, 0, 0, 0);
  413. border-bottom: 92rpx solid #ffcabb;
  414. border-left: 92rpx solid rgba(0, 0, 0, 0);
  415. transform: translate(-46rpx, -92rpx);
  416. position: absolute;
  417. top: 0;
  418. left: 0;
  419. }
  420. .samll {
  421. .p_favour{
  422. font-size: 28rpx;
  423. }
  424. }
  425. // 价格信息栏-end
  426. // 标题信息栏
  427. .goods_subName {
  428. width: 100%;
  429. overflow: hidden;
  430. font-size: 22rpx;
  431. color: #787878;
  432. }
  433. .title_info {
  434. width: 100%;
  435. overflow: hidden;
  436. background: #ffffff;
  437. padding: 20rpx;
  438. box-sizing: border-box;
  439. }
  440. .goods_name {
  441. width: 100%;
  442. overflow: hidden;
  443. font-size: 32rpx;
  444. color: #1b1b1b;
  445. font-family: "SourceHanSansCN-Bold";
  446. font-weight: bold;
  447. margin-bottom: 20rpx;
  448. }
  449. // 标题信息栏-end
  450. // 产品简介
  451. .brief {
  452. width: 100%;
  453. overflow: hidden;
  454. background-color: #fff;
  455. }
  456. .brief_con {
  457. width: 100%;
  458. overflow: hidden;
  459. padding: 20rpx;
  460. box-sizing: border-box;
  461. }
  462. .brief_title {
  463. width: 100%;
  464. overflow: hidden;
  465. font-size: 26rpx;
  466. color: #1b1b1b;
  467. padding: 0 20rpx;
  468. box-sizing: border-box;
  469. border-bottom: 3rpx solid rgba(0, 0, 0, 0.12);
  470. height: 74rpx;
  471. }
  472. // 产品简介-end
  473. // 底部导航组件
  474. .option {
  475. position: fixed;
  476. width: 100%;
  477. overflow: hidden;
  478. left: 0;
  479. bottom: 0;
  480. }
  481. // 底部导航组件-end
  482. // 购买或加入购物车弹窗
  483. .option_box text {
  484. color: #2db389;
  485. }
  486. .close_img {
  487. font-size: 38rpx;
  488. color: #999;
  489. }
  490. .option_box {
  491. font-size: 26rpx;
  492. margin-top: 80rpx;
  493. }
  494. .goods_raido:nth-last-child(1) {
  495. margin-right: 0;
  496. }
  497. .num_con {
  498. width: 100%;
  499. overflow: hidden;
  500. padding-bottom: 3rpx;
  501. }
  502. .num_str {
  503. font-size: 14px;
  504. color: #989898;
  505. }
  506. .goods_option {
  507. width: 100%;
  508. overflow: hidden;
  509. padding-top: 50rpx;
  510. }
  511. .close_con {
  512. width: 100%;
  513. overflow: hidden;
  514. margin-bottom: 35rpx;
  515. }
  516. .raido_text {
  517. font-size: 26rpx;
  518. color: #545454;
  519. margin-left: 18rpx;
  520. }
  521. .goods_con {
  522. width: calc(100% - 202rpx - 30rpx);
  523. overflow: hidden;
  524. }
  525. .goods_img {
  526. width: 202rpx;
  527. height: 187rpx;
  528. margin-right: 30rpx;
  529. border-radius: 12rpx;
  530. }
  531. .confim {
  532. width: 100%;
  533. height: 80rpx;
  534. border-radius: 40rpx;
  535. background: #2db389;
  536. color: #fff;
  537. font-size: 26rpx;
  538. margin-top: 44rpx;
  539. }
  540. .shopping {
  541. width: 100%;
  542. overflow: hidden;
  543. padding: 20rpx;
  544. box-sizing: border-box;
  545. border-radius: 30rpx 30rpx 0 0;
  546. background: #fff;
  547. }
  548. .goods_info {
  549. width: 100%;
  550. overflow: hidden;
  551. align-items: inherit;
  552. padding-bottom: 48rpx;
  553. border-bottom: 3rpx solid rgba(0, 0, 0, 0.12);
  554. }
  555. .shop_names {
  556. width: 100%;
  557. overflow: hidden;
  558. font-family: "SourceHanSansCN-Bold";
  559. font-weight: bold;
  560. color: #1b1b1b;
  561. font-size: 32rpx;
  562. }
  563. .goods_msg {
  564. width: 100%;
  565. overflow: hidden;
  566. font-size: 28rpx;
  567. color: #18bb88;
  568. font-family: "SourceHanSansCN-Medium";
  569. font-weight: 500;
  570. }
  571. .raido_img {
  572. width: 39rpx;
  573. height: 35rpx;
  574. background: url(~@/static/img/weixuanzhong.png);
  575. background-repeat: no-repeat;
  576. background-size: 35rpx 35rpx;
  577. background-position: center center;
  578. }
  579. .raido_box {
  580. background: url(~@/static/img/consent.png);
  581. background-repeat: no-repeat;
  582. background-size: 39rpx 35rpx;
  583. background-position: center center;
  584. }
  585. // 购买或加入购物车弹窗-end
  586. .goods_teac {
  587. .product-txt,
  588. .product-text {
  589. font-size: 22rpx;
  590. color: #787878;
  591. }
  592. .product-text {
  593. margin-left: 16rpx;
  594. }
  595. .red {
  596. color: #FA2E18;
  597. }
  598. .fenxiang {
  599. font-size: 22rpx;
  600. background: rgba(250, 46, 24, 0.08);
  601. display: inline-block;
  602. border-radius: 6rpx;
  603. padding: 0 16rpx;
  604. }
  605. }
  606. </style>