convert.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <view :class="[AppTheme]" v-if="cache" class="all_box">
  3. <u-toast ref="uToast" :z-index="99999999999999" />
  4. <u-modal :show="show" :show-cancel-button="true" confirm-text="去添加" :content="'请先添加默认收货地址'" @confirm="goAdd">
  5. </u-modal>
  6. <view class="carousel">
  7. <swiper indicator-dots circular="true" duration="400">
  8. <swiper-item class="swiper-item" v-for="(item, index) in appalbum" :key="index">
  9. <view class="image-wrapper">
  10. <image :src=" item" class="loaded" mode="aspectFill"></image>
  11. </view>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. <view class="title-text">
  16. <p>{{ cache.name }}</p>
  17. <p class="text-primary">
  18. {{ cache.integral }} 积分
  19. </p>
  20. </view>
  21. <view class="title-text-cnent">
  22. <span>剩余: {{ cache.num }}</span>
  23. <span>单位: {{ cache.unit }}</span>
  24. <span>销量: {{ cache.dissells }}</span>
  25. </view>
  26. <view class="bottom_img">
  27. <p class="subtitle">商品详情</p>
  28. <u-parse :content="content" class="text" :lazy-load="true" :show-with-animation="true"></u-parse>
  29. </view>
  30. <view class="page-bottom">
  31. <navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn ">
  32. <view class="">
  33. <u-icon :color="primary" labelSize="12" color="#909399" label="首页" labelPos="bottom"
  34. labelColor="#909399" size="25" name="home-fill"></u-icon>
  35. </view>
  36. </navigator>
  37. <div class=""></div>
  38. <view @click="opensharebox" class="p-b-btn " style="position: relative;">
  39. <u-icon labelSize="12" color="#909399" label="分享" labelPos="bottom" labelColor="#909399" size="25"
  40. name="share"></u-icon>
  41. </view>
  42. <view class="action-btn-group">
  43. <button type="primary" class=" action-btn no-border buy-now-btn bg-linear-gradient"
  44. @click="purchasing">立即兑换</button>
  45. </view>
  46. <!-- 分享 -->
  47. <sharebox ref="sbox" v-if="sharedata" :data="sharedata"></sharebox>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import api_address from '@/api/address/address.js';
  53. import api from '@/api/mall/index.js';
  54. export default {
  55. data() {
  56. return {
  57. primary: this.$theme.primary,
  58. sharedata: null,
  59. num: 0,
  60. shows: false,
  61. show: false,
  62. cache: '',
  63. apppic: '',
  64. appalbum: [],
  65. settingFile: getApp().globalData.siteinfo,
  66. id: '',
  67. content: '',
  68. addressData: '',
  69. };
  70. },
  71. onLoad(options) {
  72. this.$bindid.getbindid(options, this.$store);
  73. this.id = options.id;
  74. this.goods(options.id || "3");
  75. },
  76. onShow() {
  77. this.getAddressData()
  78. },
  79. onShareAppMessage(res) {
  80. let that = this
  81. let data = {
  82. title: that.sharedata.title,
  83. imageUrl: that.sharedata.imageUrl,
  84. path: that.sharedata.path
  85. };
  86. return data;
  87. },
  88. onShareTimeline(res) {
  89. let that = this
  90. return {
  91. title: that.sharedata.title,
  92. imageUrl: that.sharedata.imageUrl,
  93. path: that.sharedata.path
  94. }
  95. },
  96. methods: {
  97. opensharebox() {
  98. this.$refs.sbox.opensharebox(this.sharedata);
  99. },
  100. /* 去添加收货地址 */
  101. goAdd() {
  102. this.show = false;
  103. uni.navigateTo({
  104. url: '/pagesD/pages/address/address?source=1'
  105. })
  106. },
  107. getAddressData() {
  108. api_address.address().then(res => {
  109. if (res.status == 200) {
  110. let is_default = res.data.data.filter(item => item.is_default == 1);
  111. this.addressData = is_default[0];
  112. if (!this.addressData) {
  113. this.show = true;
  114. }
  115. }
  116. });
  117. },
  118. goods(id) {
  119. api.shoopgoods({
  120. id
  121. }).then(res => {
  122. console.log(res)
  123. if (res.status == 200) {
  124. this.data = res.data;
  125. this.cache = res.data.cache;
  126. this.apppic = res.data.apppic;
  127. this.appalbum = res.data.appalbum;
  128. this.sharedata = res.data.sharedata
  129. this.sharedata.title = res.data.cache.name;
  130. this.sharedata.path = '/pagesD/pages/mall/convert?pid=' + this
  131. .$getuid() + '&id=' + id;
  132. /* 处理富文本*/
  133. this.content = this.cache.content.replace(/\<img src="/gi,
  134. `<img style='width:100%;display:block' src="${this.settingFile.root_rich_img}`);
  135. } else {
  136. this.$refs.uToast.show({
  137. title: res.msg,
  138. type: 'error'
  139. });
  140. }
  141. });
  142. },
  143. purchasing() {
  144. this.go();
  145. },
  146. close() {
  147. },
  148. valChange(e) {
  149. console.log(e);
  150. },
  151. go() {
  152. console.log('this.addressData ',this.addressData )
  153. if (!this.addressData) {
  154. this.show = true;
  155. console.log('this.show ',this.show )
  156. return;
  157. }
  158. if (this.cache.num - this.num < 0) {
  159. this.$refs.uToast.show({
  160. title: '该产品库存不足!',
  161. type: 'error'
  162. });
  163. return;
  164. }
  165. const data = {
  166. sid: 0,
  167. goodstype: this.cache.type,
  168. goodsid: this.cache.id,
  169. num: this.num,
  170. isame: this.data.isame
  171. };
  172. console.log(data);
  173. api.fastbuys(data).then(res => {
  174. if (res.status == 200) {
  175. uni.showToast({
  176. icon: 'loading',
  177. title: '生成订单',
  178. duration: 2000
  179. })
  180. setTimeout(() => {
  181. this.$u.route('/pagesD/pages/order/integrals/integrals', {
  182. id: this.id,
  183. sid: 0,
  184. lasturl: this.data.lasturl
  185. });
  186. }, 2000);
  187. } else {
  188. this.$u.toast(res.msg);
  189. }
  190. });
  191. }
  192. }
  193. };
  194. </script>
  195. <style lang="scss">
  196. .all_box {
  197. .page-bottom {
  198. position: fixed;
  199. left: 0;
  200. bottom: 0;
  201. z-index: 95;
  202. display: flex;
  203. justify-content: center;
  204. align-items: center;
  205. width: 100%;
  206. height: 100upx;
  207. background: rgba(255, 255, 255, 0.9);
  208. box-shadow: 0 0 20upx 0 rgba(0, 0, 0, 0.5);
  209. .p-b-btn {
  210. display: flex;
  211. flex-direction: column;
  212. align-items: center;
  213. margin: 0 19rpx;
  214. justify-content: center;
  215. font-size: $font-sm;
  216. color: $font-color-base;
  217. width: 96upx;
  218. height: 80upx;
  219. .yticon {
  220. font-size: 40upx;
  221. line-height: 48upx;
  222. color: $font-color-light;
  223. }
  224. &.active,
  225. &.active .yticon {
  226. color: $tab-color-1;
  227. }
  228. .icon-fenxiang2 {
  229. font-size: 42upx;
  230. transform: translateY(-2upx);
  231. }
  232. .icon-shoucang {
  233. font-size: 46upx;
  234. }
  235. }
  236. .action-btn-group {
  237. display: flex;
  238. height: 76upx;
  239. border-radius: 100px;
  240. overflow: hidden;
  241. box-shadow: 0 20upx 40upx -16upx $tab-color;
  242. // background: linear-gradient(to right, #ffac30);
  243. margin-left: 20upx;
  244. position: relative;
  245. &:after {
  246. content: '';
  247. position: absolute;
  248. top: 50%;
  249. right: 50%;
  250. transform: translateY(-50%);
  251. height: 28upx;
  252. width: 0;
  253. }
  254. .action-btn {
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. width: 400rpx;
  259. height: 100%;
  260. font-size: $font-base;
  261. padding: 0;
  262. border-radius: 0;
  263. }
  264. }
  265. }
  266. .box_top {
  267. height: 210rpx;
  268. padding: 30rpx;
  269. box-sizing: border-box;
  270. display: flex;
  271. position: relative;
  272. border-bottom: 0.5rpx solid #efefef;
  273. .icon-close {
  274. position: absolute;
  275. right: 20rpx;
  276. top: 20rpx;
  277. }
  278. .left_img {
  279. image {
  280. width: 150rpx;
  281. height: 150rpx;
  282. }
  283. }
  284. .content_text {
  285. margin-left: 24rpx;
  286. height: 150rpx;
  287. width: 236rpx * 2;
  288. p:nth-child(1) {
  289. font-size: 30rpx;
  290. margin: 5rpx 0 15rpx 0;
  291. line-height: 40rpx;
  292. display: -webkit-box;
  293. -webkit-box-orient: vertical;
  294. -webkit-line-clamp: 3;
  295. overflow: hidden;
  296. }
  297. p:nth-child(2) {
  298. font-size: 28rpx;
  299. color: #fe4535;
  300. margin: 0rpx 0 5rpx 0;
  301. }
  302. p:nth-child(3) {
  303. font-size: 24rpx;
  304. text-decoration: line-through;
  305. color: #999999;
  306. margin-left: 10rpx;
  307. }
  308. }
  309. }
  310. .box_bot {
  311. height: 144rpx;
  312. padding: 30rpx;
  313. box-sizing: border-box;
  314. display: flex;
  315. justify-content: space-between;
  316. .pedometer {
  317. display: flex;
  318. align-items: center;
  319. }
  320. }
  321. .box_button {}
  322. }
  323. .text {
  324. background: #fff;
  325. padding: 20rpx 20rpx 50rpx 20rpx;
  326. line-height: 41rpx;
  327. }
  328. .carousel {
  329. height: 722upx;
  330. position: relative;
  331. swiper {
  332. height: 100%;
  333. }
  334. .image-wrapper {
  335. width: 100%;
  336. height: 100%;
  337. }
  338. .swiper-item {
  339. display: flex;
  340. justify-content: center;
  341. align-content: center;
  342. height: 750upx;
  343. overflow: hidden;
  344. image {
  345. width: 100%;
  346. height: 100%;
  347. }
  348. }
  349. }
  350. .title-text {
  351. padding: 30rpx;
  352. box-sizing: border-box;
  353. margin: 10rpx;
  354. // width: 100%;
  355. background-color: #fff;
  356. display: flex;
  357. justify-content: space-between;
  358. p:nth-child(1) {
  359. width: 80%;
  360. font-size: 30rpx;
  361. }
  362. p:nth-child(2) {
  363. font-size: 32rpx;
  364. span {
  365. text-decoration: line-through;
  366. margin: 0 20rpx;
  367. font-size: 24rpx;
  368. color: #999999;
  369. }
  370. }
  371. }
  372. .title-text-cnent {
  373. padding: 30rpx;
  374. box-sizing: border-box;
  375. margin: 10rpx;
  376. height: 90rpx;
  377. // width: 100%;
  378. background-color: #fff;
  379. display: flex;
  380. justify-content: space-between;
  381. font-size: 26rpx;
  382. color: #999999;
  383. }
  384. .detriment {
  385. position: fixed;
  386. bottom: 0;
  387. left: 0;
  388. width: 100%;
  389. }
  390. .bottom_img {
  391. .content-box {
  392. display: flex;
  393. justify-content: center;
  394. image {}
  395. }
  396. }
  397. .subtitle {
  398. position: relative;
  399. font-size: 0.24rem;
  400. color: #999999;
  401. height: 45px;
  402. line-height: 45px;
  403. text-align: center;
  404. font-size: 14px;
  405. background-color: #FFFFFF;
  406. margin-bottom: 20rpx;
  407. &:before {
  408. content: '';
  409. position: absolute;
  410. width: 10%;
  411. height: 1px;
  412. top: 50%;
  413. background-color: #999999;
  414. left: 25%;
  415. }
  416. &:after {
  417. content: '';
  418. position: absolute;
  419. width: 10%;
  420. height: 1px;
  421. top: 50%;
  422. background-color: #999999;
  423. right: 25%;
  424. }
  425. }
  426. </style>
  427. <style>
  428. </style>