p_details.vue 14 KB

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