resource.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view>
  3. <!--标题栏-->
  4. <bar-title bgColor='bg-white'>
  5. <block slot="content">商品详情</block>
  6. <block slot="right">
  7. <text :class="isFavor ? 'cuIcon-favorfill' : 'cuIcon-favor'" @click="favTap"/>
  8. <text class="cuIcon-forward"/>
  9. </block>
  10. </bar-title>
  11. <!--提示-->
  12. <!-- <view class="bg-grey text-sm text-center padding-tb-xs text-white">真机实拍部分为真机样张,您购买的机型大致符合图中成色效果</view> -->
  13. <!--轮播图-->
  14. <view class="zaiui-banner-swiper-box">
  15. <swiper class="screen-swiper" circular autoplay @change="bannerSwiper">
  16. <swiper-item v-for="(item,index) in info.pic" :key="index">
  17. <image :src="item" mode="aspectFill"/>
  18. </swiper-item>
  19. </swiper>
  20. <!--页码-->
  21. <text v-if="info.pic" class="cu-tag bg-grey round sm zaiui-page">{{bannerCur + 1}} / {{info.pic.length}}</text>
  22. </view>
  23. <!--限时秒杀-->
  24. <view class="zaiui-limited-seckill-box">
  25. <view class="zaiui-time-left">
  26. <text class="text-price text-xxl">{{info.price ? info.price.value : '0'}}</text>
  27. <view class="text-xs zaiui-cost-price-num price-4">
  28. <view class="text-through">原价{{info.price ? info.price.original : 0}}</view>
  29. <!-- <view>剩余{{info.price.num}}件</view> -->
  30. </view>
  31. </view>
  32. <view class="text-right zaiui-time-right">
  33. <!-- <view>自营限时秒杀</view>
  34. <view class="text-xs">距结束剩余10时07分50秒</view> -->
  35. </view>
  36. </view>
  37. <!--标题-->
  38. <view class="bg-white zaiui-view-box zaiui-title-view-box">
  39. <view class="title-view">
  40. <!-- <text class="cu-tag bg-red radius sm">自营</text> -->
  41. <text class="text-black text-lg text-bold">{{info.name}}</text>
  42. </view>
  43. <!-- <view class="light bg-red radius margin-top-sm zaiui-title-tip-box">
  44. <view class="text-cut">
  45. <text class="margin-right-sm">官方自营</text>
  46. <text class="text-sm">官方自营正品保障新品体验售后无忧</text>
  47. </view>
  48. <text class="cuIcon-right icon"/>
  49. </view> -->
  50. </view>
  51. <!--评论-->
  52. <!-- <view class="margin-top bg-white zaiui-comment-view-box">
  53. <view class="cu-bar bg-white">
  54. <view class="action">
  55. <text class="text-black text-lg">评价(3699)</text>
  56. </view>
  57. <view class="action">
  58. <view class="text-sm">
  59. <text class="margin-right-xs">好评率</text>
  60. <text class="text-black text-lg">97%</text>
  61. <text class="cuIcon-right icon margin-left-xs"/>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="zaiui-border-view"/>
  66. <view class="zaiui-view-box">
  67. <view class="flex flex-wrap text-sm">
  68. <view class="basis-1">
  69. <view class="cu-avatar sm round" style="background-image:url(/static/images/avatar/1.jpg)"/>
  70. </view>
  71. <view class="basis-9 text-sm">
  72. <view>仔仔</view>
  73. <view class="margin-top-xs">X真的是我觉得性价比最高的机器了,大小合适,全面屏操作流畅,灰色也很漂亮,超喜欢</view>
  74. <view class="text-gray margin-top-sm">iPhone X 64G深空灰色</view>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="zaiui-border-view"/>
  79. <view class="zaiui-view-box">
  80. <view class="flex flex-wrap text-sm">
  81. <view class="basis-1">
  82. <view class="cu-avatar sm round" style="background-image:url(/static/images/avatar/2.jpg)"/>
  83. </view>
  84. <view class="basis-9 text-sm">
  85. <view>仔仔</view>
  86. <view class="margin-top-xs">X真的是我觉得性价比最高的机器了,大小合适,全面屏操作流畅,灰色也很漂亮,超喜欢</view>
  87. <view class="text-gray margin-top-sm">iPhone X 64G深空灰色</view>
  88. </view>
  89. </view>
  90. </view>
  91. </view> -->
  92. <!--图片详情-->
  93. <view class="margin-top zaiui-goods-details-box" v-html="info.content" style="padding:0 26upx">
  94. <!-- <image src="/static/images/home/goods/goods-1.png" mode="widthFix"/>
  95. <image src="/static/images/home/goods/goods-2.png" mode="widthFix"/> -->
  96. </view>
  97. <!--占位底部距离-->
  98. <view class="cu-tabbar-height"/>
  99. <!--底部操作-->
  100. <view class="zaiui-footer-fixed">
  101. <view class="cu-bar bg-white tabbar border shop" style="padding: 0 32upx;">
  102. <button class="cu-btn bg-red radius shadow-blur" style="flex: 1;" @tap="selectTap('sell')">{{skuInfo.button}}</button>
  103. </view>
  104. </view>
  105. <!--弹出框-->
  106. <view class="cu-modal bottom-modal zaiui-bottom-modal-box" :class="bottomModal?'show':''">
  107. <view class="cu-dialog bg-white">
  108. <!--标题-->
  109. <view class="text-black text-center margin-tb text-lg zaiui-title-bar">
  110. <text>{{modalTitle}}</text>
  111. <text class="cuIcon-close close-icon" @tap="hideModal"></text>
  112. </view>
  113. <!--内容区域-->
  114. <view class="zaiui-modal-content">
  115. <view class="zaiui-view-box service" >
  116. <view class="text-view">
  117. <text class="cuIcon-title text-red"/>
  118. <text class="text-cut text-black">价格</text>
  119. </view>
  120. <view class="text-sm text-list-view">
  121. <view class="margin-left text-gray">{{skuInfo.text}}</view>
  122. </view>
  123. <block v-if="skuInfo.status != 2">
  124. <view class="text-view">
  125. <text class="cuIcon-title text-red"/>
  126. <text class="text-cut text-black">详情</text>
  127. </view>
  128. <view class="text-sm text-list-view" v-for="item in skuInfo.value">
  129. <view class="margin-left text-gray" v-if="!item.file">{{item.content}}</view>
  130. <view class="margin-left text-cut text-gray" v-else><a :href="item.file" target="_blank">{{item.file}}</a></view>
  131. </view>
  132. </block>
  133. </view>
  134. <!--公共按钮-->
  135. <view class="zaiui-footer-fixed">
  136. <view class="flex flex-direction">
  137. <button class="cu-btn bg-red lg" @click="payResource">确定</button>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. import barTitle from '@/components/zaiui-common/basics/bar-title';
  147. import _tool from '@/static/zaiui/util/tools.js'; //工具函数
  148. export default {
  149. components: {
  150. barTitle,
  151. },
  152. data() {
  153. return {
  154. bannerCur: 0, bannerList: [], bottomModal: false, modalTitle: '', modalType: 'promotion', selectType: '',
  155. goodsList: [],
  156. goodsId: '',
  157. info: {},
  158. skuInfo: {},
  159. selectedSku: '',
  160. cartInfo: {},
  161. isFavor: false
  162. }
  163. },
  164. onLoad(options) {
  165. this.goodsId = options.id;
  166. this.loadInfo()
  167. this.loadSku()
  168. },
  169. onReady() {
  170. _tool.setBarColor(true);
  171. uni.pageScrollTo({
  172. scrollTop: 0,
  173. duration: 0
  174. });
  175. },
  176. computed: {
  177. curSkuArr() {
  178. return this.selectedSku.split('_')
  179. },
  180. selectedSkuName() {
  181. let arr = []
  182. if(!this.skuInfo.sku || !this.curSkuArr.length) {
  183. return ''
  184. }
  185. this.curSkuArr.forEach((item, index) => {
  186. let o = this.skuInfo.sku.spec[index] || {};
  187. arr.push(o.name + ':' + (o ? o.value : []).find(v => v.id == item).value)
  188. })
  189. return arr.join(',');
  190. },
  191. totalCount() {
  192. if(!this.cartInfo.length) {
  193. return 0
  194. }
  195. return this.cartInfo.reduce((prev, curr) => {
  196. return prev + curr.num
  197. }, 0)
  198. }
  199. },
  200. methods: {
  201. favTap() {
  202. this.reqByuser({
  203. url: '?l=collect.up',
  204. data: {type: 1, type_id: this.goodsId},
  205. success: res => {
  206. if(res.data.status == 1) {
  207. this.isFavor = true;
  208. }else {
  209. this.error = res.data.msg
  210. }
  211. }
  212. })
  213. },
  214. loadInfo() {
  215. this.req({
  216. url: '?l=resource.view',
  217. data: {type: 1, type_id: this.goodsId},
  218. success: res => {
  219. if(res.data.status == 1) {
  220. this.info = res.data.data.info;
  221. }else {
  222. this.error = res.data.msg
  223. }
  224. }
  225. })
  226. },
  227. loadSku() {
  228. this.reqByuser({
  229. url: '?l=resource.submit',
  230. data: {type: 1, type_id: this.goodsId},
  231. success: res => {
  232. if(res.data.status == 1) {
  233. // console.log(res.data.data)
  234. this.skuInfo = res.data.data.info;
  235. }else {
  236. this.error = res.data.msg
  237. }
  238. }
  239. })
  240. },
  241. bannerSwiper(e) {
  242. this.bannerCur = e.detail.current;
  243. },
  244. serviceTap() {
  245. this.modalTitle = "服务";
  246. this.modalType = 'service';
  247. this.showModal();
  248. },
  249. promotionTap() {
  250. this.modalTitle = "促销优惠";
  251. this.modalType = 'promotion';
  252. this.showModal();
  253. },
  254. selectTap(type) {
  255. this.selectType = type;
  256. this.modalTitle = "立即购买";
  257. this.modalType = 'select';
  258. this.showModal();
  259. },
  260. showModal() {
  261. this.bottomModal = true;
  262. },
  263. hideModal(e) {
  264. this.bottomModal = false;
  265. this.modalTitle = "";
  266. this.modalType = '';
  267. },
  268. myCartTap(){
  269. uni.navigateTo({
  270. url: '/pages/goods/my_cart'
  271. });
  272. },
  273. loadCartList() {
  274. this.reqByuser({
  275. url: '?l=cart.list',
  276. data: {},
  277. success: res => {
  278. if(res.data.status == 1) {
  279. // console.log(res.data.data)
  280. // this.cartInfo = res.data.data.info;
  281. this.cartInfo = res.data.data.list
  282. }else {
  283. this.error = res.data.msg
  284. }
  285. }
  286. })
  287. },
  288. payResource() {
  289. this.reqByuser({
  290. url: '?l=resource.pay',
  291. // method: 'POST',
  292. data: {
  293. type: 1,
  294. type_id: this.goodsId,
  295. num: 1,
  296. account: 'wechat',
  297. env: 3
  298. },
  299. success: res => {
  300. if(res.data.status == 1) {
  301. location.href = res.data.data.pay.link;
  302. this.bottomModal = false;
  303. this.loadSku()
  304. }else {
  305. uni.showToast({
  306. icon: 'error',
  307. title: '添加失败'
  308. })
  309. }
  310. }
  311. })
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss">
  317. /* #ifdef APP-PLUS */
  318. @import "../../static/colorui/main.css";
  319. @import "../../static/colorui/icon.css";
  320. @import "../../static/zaiui/style/app.scss";
  321. /* #endif */
  322. @import "../../static/zaiui/style/goods.scss";
  323. </style>