productInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <gracePage headerBG="#FFFFFF" footerBg="#FFFFFF" :customHeader="false">
  3. <view slot="gBody" style="padding-bottom:120rpx;">
  4. <!-- 轮播图 -->
  5. <swiper class="grace-swiper" autoplay="true" indicator-dots
  6. indicator-color="rgba(255, 255, 255, 1)" indicator-active-color="#3688FF"
  7. style="height:399rpx" interval="5000">
  8. <swiper-item class="grace-swiper-item" v-for="(item, index) in swiperItems" :key="index">
  9. <image :src="item" mode="widthFix" class="grace-swiper-image"></image>
  10. </swiper-item>
  11. </swiper>
  12. <!-- 商品标题 分享按钮 -->
  13. <view class="grace-product-padding grace-space-between grace-flex-vcenter">
  14. <text class="grace-product-title grace-bold">{{product.name}}</text>
  15. <view class="grace-product-share" @tap="share"><text class="grace-icons icon-share3"></text></view>
  16. </view>
  17. <view class="grace-common-line"></view>
  18. <!-- 价格 -->
  19. <view class="grace-product-padding">
  20. <view class="grace-nowrap grace-flex-vcenter">
  21. <text class="grace-product-price">¥{{product.price}}</text>
  22. <text class="grace-text grace-gray grace-line-through" style="margin-left:30rpx;">¥{{product.priceMarket}}</text>
  23. </view>
  24. <view class="grace-space-between grace-flex-vcenter">
  25. <text class="grace-text-small grace-gray">运费 ¥0.00</text>
  26. <text class="grace-text-small grace-gray">已售 21008 件</text>
  27. <text class="grace-text-small grace-gray">浏览 36万次</text>
  28. </view>
  29. </view>
  30. <view class="grace-common-line"></view>
  31. <!-- 底部信息切换导航 -->
  32. <view class="grace-product-padding">
  33. <graceNavBar :items="navItems" lineHeight="80rpx" :isCenter="true"
  34. :currentIndex="active" :size="200" activeLineBg="#FF7900" textAlign="center"
  35. activeColor="#FF7900" activeLineWidth="200rpx" activeLineHeight="2rpx"
  36. :margin="10" @change="navChange"></graceNavBar>
  37. </view>
  38. <!-- 详情 请根据项目情况自行改进 可以使用 富文本-->
  39. <view class="grace-product-padding" :hidden="active == 1">
  40. <image class="grace-product-info-img" :src="item" mode="widthFix" v-for="(item,index) in product.imgs" :key="index"></image>
  41. </view>
  42. <!-- 评论区 -->
  43. <view class="grace-comments grace-product-padding" :hidden="active == 0">
  44. <view class="grace-comments-items" v-for="(item, index) in commentContents" :key="index">
  45. <image :src="item.face" class="grace-comments-face"></image>
  46. <view class="grace-comments-body">
  47. <view class="grace-comments-header">
  48. <text class="grace-comments-header-text">{{item.name}}</text>
  49. <text class="grace-comments-info-text">{{item.date}}</text>
  50. </view>
  51. <text class="grace-comments-content">{{item.content}}</text>
  52. <view class="grace-comments-imgs" v-if="item.imgs">
  53. <view class="grace-comments-image" v-for="(img, indexImg) in item.imgs" :key="indexImg">
  54. <image :src="img" mode="widthFix" class="grace-comments-img" @click.stop="showImgs(index, indexImg)"></image>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 属性选择 -->
  61. <graceBottomDialog :show="attrIsShow" @closeDialog="closeAttr">
  62. <form @submit="attrSubmit" style="box-sizing:border-box; padding:10rpx 25rpx;" class="grace-form" slot="content">
  63. <!-- 关闭按钮 -->
  64. <view class="grace-nowrap grace-flex-end">
  65. <text class="grace-icons icon-close" @tap="closeAttr"></text>
  66. </view>
  67. <!-- 头部商品信息 -->
  68. <view class="grace-product-attr-info">
  69. <image class= "grace-product-attr-info-image" mode="widthFix"
  70. src="https://img13.360buyimg.com/n7/jfs/t1/9085/2/12381/146200/5c371c5bE08328383/4f4ba51aed682207.jpg"></image>
  71. <view class="grace-product-attr-info-body">
  72. <text class="grace-product-attr-info-title">{{product.name}}</text>
  73. <text class="grace-product-attr-info-stone">库存 : 1999件</text>
  74. </view>
  75. </view>
  76. <!-- 属性列表区 -->
  77. <scroll-view style="height:700rpx;" scroll-y>
  78. <view class="grace-title grace-margin-top">选择颜色</view>
  79. <view><graceSelectTags selectedColor="#FF0036" :items="colorTips" type="radio" @change="change1"></graceSelectTags></view>
  80. <view class="grace-title grace-margin-top">选择类型</view>
  81. <view><graceSelectTags selectedColor="#FF0036" :items="typeTips" type="radio" @change="change2"></graceSelectTags></view>
  82. <view class="grace-margin-top"><text class="grace-title">购买数量</text></view>
  83. <view>
  84. <graceNumberBox :value="buyNum" v-on:change="buyNumChange"></graceNumberBox>
  85. </view>
  86. </scroll-view>
  87. <view class="grace-product-attr-btn">
  88. <button type="warn" style="background-color:#FF0036;" class="grace-button grace-border-radius" formType="submit">立即购买</button>
  89. </view>
  90. </form>
  91. </graceBottomDialog>
  92. </view>
  93. <!-- 底部 -->
  94. <view class="grace-space-between grace-flex-vcenter grace-bg-white" slot="gFooter">
  95. <view class="grace-grids grace-nowrap" style="width:250rpx;">
  96. <view class="grace-grids-items grace-relative" @tap="gohome">
  97. <text class="grace-grids-icon grace-icons icon-home"></text>
  98. <text class="grace-grids-text grace-grids-text">首页</text>
  99. </view>
  100. <view class="grace-grids-items grace-relative">
  101. <text class="grace-grids-icon grace-grids-icon grace-icons icon-shoucang grace-footer-active"></text>
  102. <text class="grace-grids-text grace-grids-text grace-footer-active">收藏</text>
  103. </view>
  104. </view>
  105. <view class="grace-flex-end" style="width:460rpx;">
  106. <button type="warn" class="grace-footer-button" style="background:#E55D52;" @tap="buyNow">立即购买</button>
  107. <button type="warn" class="grace-footer-button" style="background:#F37B1D;" @tap="buyNow">加入购物车</button>
  108. </view>
  109. </view>
  110. </gracePage>
  111. </template>
  112. <script>
  113. import gracePage from "../../graceUI/components/gracePage.vue";
  114. import graceNavBar from "../../graceUI/components/graceNavBar.vue";
  115. import graceBottomDialog from '../../graceUI/components/graceBottomDialog.vue';
  116. import graceNumberBox from '../../graceUI/components/graceNumberBox.vue';
  117. import graceSelectTags from '../../graceUI/components/graceSelectTags.vue';
  118. export default {
  119. data() {
  120. return {
  121. // 轮播图
  122. swiperItems : [
  123. 'http://i1.mifile.cn/f/i/2019/C76029A6/part6-2.jpg',
  124. 'http://i1.mifile.cn/f/i/2019/C76029A6/part6-2.jpg',
  125. 'http://i1.mifile.cn/f/i/2019/C76029A6/part6-2.jpg'
  126. ],
  127. // 切换导航
  128. navItems : ['商品详情', '相关评论'],
  129. active:0,
  130. product : {
  131. name: "小米 MIX3 一面科技 一面艺术 ( 磁动力滑盖全面屏 | 故宫特别版 )",
  132. logo : "../../static/logo.png",
  133. price : 3188,
  134. priceMarket : 3200,
  135. imgs : [
  136. 'https://img30.360buyimg.com/sku/jfs/t21838/18/2275707529/311540/cba1d04c/5b4f155fNac3aa2f0.jpg',
  137. 'https://img30.360buyimg.com/sku/jfs/t22021/327/2281785192/48707/57806074/5b4f1579Nae7adb49.jpg',
  138. 'https://img30.360buyimg.com/sku/jfs/t21682/256/2344553276/204456/cf7a2ddb/5b4ffbbfN48c54307.jpg'
  139. ]
  140. },
  141. // 模拟评论数据 (实际项目来自api请求)
  142. commentContents : [
  143. {
  144. "content":"故国三千里,深宫二十年。一声何满子,双泪落君前。",
  145. "name":"graceUI - 小码",
  146. "face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png",
  147. "date":"08/10 08:00"
  148. },
  149. {
  150. "content":"而今渐行渐远,渐觉虽悔难追。漫寄消寄息,终久奚为。也拟重论缱绻,争奈翻覆思维。纵再会,只恐恩情,难似当时。",
  151. "name":"路过繁华",
  152. "face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
  153. "date":"02/10 18:00"
  154. },
  155. {
  156. "content":"图片回复,点击图片可以预览......",
  157. "name":"林夕阳",
  158. "imgs" : [
  159. "https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png",
  160. "https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png",
  161. "https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png",
  162. ],
  163. "face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
  164. "date":"08/12 09:00"
  165. }
  166. ],
  167. // 购买选择属性层展示
  168. attrIsShow : false,
  169. colorTips : [
  170. { name: '灰色', value: '灰色', checked: true },
  171. { name: '银色', value: '银色', checked: false}
  172. ],
  173. colorSelected : "灰色",
  174. typeTips : [
  175. { name: '套餐一', value: '套餐一', checked: true },
  176. { name: '套餐二', value: '套餐二', checked: false},
  177. { name: '套餐三', value: '套餐三', checked: false}
  178. ],
  179. typeSelected : "套餐一",
  180. buyNum : 1
  181. }
  182. },
  183. onLoad:function () {},
  184. methods:{
  185. // 分享
  186. share: function(){uni.showToast({title:'请自行完善分享代码', icon: "none"});},
  187. // 导航切换
  188. navChange : function(e){
  189. this.active = e;
  190. },
  191. // 评论图片展示
  192. showImgs : function(commentsIndex, imgIndex){
  193. console.log(commentsIndex, imgIndex);
  194. uni.previewImage({
  195. urls:this.commentContents[commentsIndex].imgs,
  196. current:this.commentContents[commentsIndex].imgs[imgIndex]
  197. })
  198. },
  199. //打开属性视图
  200. buyNow : function(){this.attrIsShow = true;},
  201. // 关闭属性
  202. closeAttr : function(){this.attrIsShow = false;},
  203. // 颜色选择
  204. change1 : function (e) {this.colorSelected = e;},
  205. // 类型选择
  206. change2 : function (e) {this.typeSelected = e;},
  207. // 购买数量变化
  208. buyNumChange : function (e) {
  209. this.buyNum = e[0];
  210. },
  211. // 属性提交
  212. attrSubmit : function(e){
  213. //后续操作
  214. uni.showToast({
  215. title:"属性已经收集,请观察控制台",
  216. icon:"none"
  217. });
  218. console.log("颜色 : " + this.colorSelected, "类型 : " + this.typeSelected , '数量 : ' + this.buyNum);
  219. //如果想关闭属性
  220. this.closeAttr();
  221. },
  222. // 返回首页
  223. gohome : function(){
  224. uni.switchTab({
  225. url:'../index/index'
  226. });
  227. }
  228. },
  229. components:{gracePage, graceNavBar, graceBottomDialog, graceSelectTags, graceNumberBox}
  230. }
  231. </script>
  232. <style>
  233. .grace-common-line{height:16rpx;}
  234. .grace-product-padding{padding:20rpx 25rpx;}
  235. .grace-product-title{line-height:44rpx; font-size:28rpx;}
  236. .grace-product-share{width:80rpx; height:80rpx; text-align:center; font-size:40rpx; color:#FF7900; line-height:80rpx; flex-shrink:0; margin-left:12px;}
  237. .grace-product-share:after{width:0; height:0;}
  238. .grace-product-price{color:#FF7900; line-height:60rpx; font-size:30rpx; font-weight:bold;}
  239. .grace-product-info-img{width:100%;}
  240. .grace-product-attr-info{overflow:hidden; display:flex; justify-content:space-between; border-bottom:1px solid #F1F1F3; padding-bottom:26rpx;}
  241. .grace-product-attr-info-image{width:120rpx; height:auto; margin-right:10px; flex-shrink:0;}
  242. .grace-product-attr-info-body{width:700rpx;}
  243. .grace-product-attr-info-title{width:100%; font-size:28rpx; color:#333333; display:block;}
  244. .grace-product-attr-info-stone{width:100%; font-size:20rpx; margin-top:8rpx; color:#666666; display:block;}
  245. .icon-close{font-size:30rpx; line-height:80rpx; color:#888888;}
  246. /* 调整宫格大小 */
  247. .grace-grids-items{padding:6rpx 0; width:120rpx;}
  248. .grace-grids-icon{height:50rpx; line-height:50rpx; font-size:40rpx; color:#6B7375;}
  249. .grace-grids-text{line-height:28rpx; font-size:20rpx; margin-top:2px; color:#6B7375;}
  250. .grace-footer-active{color:#FF0036;}
  251. </style>