index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y="true" class="scroll-view">
  4. <view class="list-scroll-view">
  5. <view class="one">
  6. <view class="one_1">
  7. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
  8. indicator-active-color="#007AFF" :interval="3000" :duration="1000">
  9. <swiper-item class="list" v-for="(item,index) in fileList" :key="index">
  10. <image class="image" :src="item.url" mode="aspectFit">
  11. </image>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. <view class="one_2">
  16. <text class="money"><text>¥</text>{{info.money||0}}</text>
  17. </view>
  18. <view class="one_3">
  19. <text class="num">已售{{info&&info.sell_num||0}}件</text>
  20. </view>
  21. <view class="one_4">
  22. <view class="name">
  23. {{info&&info.name}}
  24. </view>
  25. <view class="brief">
  26. {{info&&info.brief||''}}
  27. </view>
  28. </view>
  29. <view class="one_5">
  30. <view class="list" v-for="(item,index) in fileList" :key="index">
  31. <image class="image" :src="item.url" mode="aspectFit">
  32. </image>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </scroll-view>
  38. <view class="bottom">
  39. <uni-goods-nav :fill="true" :options="options" :button-group="buttonGroup" @click="onClick"
  40. @buttonClick="buttonClick" style="margin-top: 20px;" />
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. // 系统设置
  49. config: {},
  50. // 商品id
  51. id: '',
  52. // 当前用户信息
  53. user: {},
  54. // 商品详情
  55. info: {},
  56. // 轮播图
  57. fileList: [],
  58. // 底部商品导航
  59. options: [{
  60. icon: 'shop',
  61. text: '店铺'
  62. },
  63. {
  64. icon: 'cart',
  65. text: '购物车',
  66. info: 2,
  67. infoBackgroundColor: '#007aff',
  68. infoColor: "#f5f5f5"
  69. }
  70. ],
  71. buttonGroup: [{
  72. text: '加入购物车',
  73. backgroundColor: 'linear-gradient(90deg, #1E83FF, #0053B8)',
  74. color: '#fff'
  75. }],
  76. }
  77. },
  78. onLoad: async function(e) {
  79. const that = this;
  80. that.$set(that, `id`, e.id || '');
  81. that.searchConfig();
  82. await that.search();
  83. },
  84. onShow: async function() {
  85. const that = this;
  86. that.searchToken();
  87. },
  88. methods: {
  89. searchToken() {
  90. const that = this;
  91. try {
  92. const res = uni.getStorageSync('token');
  93. if (res) that.$set(that, `user`, res);
  94. } catch (e) {
  95. uni.showToast({
  96. title: err.errmsg,
  97. icon: 'error',
  98. duration: 2000
  99. });
  100. }
  101. },
  102. searchConfig() {
  103. const that = this;
  104. try {
  105. const res = uni.getStorageSync('config');
  106. if (res) that.$set(that, `config`, res);
  107. } catch (e) {
  108. uni.showToast({
  109. title: err.errmsg,
  110. icon: 'error',
  111. duration: 2000
  112. });
  113. }
  114. },
  115. // 查询商品详情
  116. async search() {
  117. const that = this;
  118. let res;
  119. res = await that.$api(`/Good/${that.id}`, 'GET', {})
  120. if (res.errcode == '0') {
  121. const arr = await that.$api(`/Specs`, 'GET', {
  122. goods: res.data._id,
  123. is_use: '0'
  124. })
  125. if (arr.errcode == '0') {
  126. let data = arr.data.sort((a, b) => {
  127. return a.money - b.money
  128. })
  129. if (data) res.data.money = data[0].money
  130. that.$set(that, `info`, res.data);
  131. that.$set(that, `fileList`, res.data.file);
  132. }
  133. }
  134. },
  135. onClick(e) {
  136. uni.showToast({
  137. title: `点击${e.content.text}`,
  138. icon: 'none'
  139. })
  140. },
  141. buttonClick(e) {
  142. console.log(e)
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .content {
  149. display: flex;
  150. flex-direction: column;
  151. width: 100vw;
  152. height: 100vh;
  153. .one {
  154. position: relative;
  155. flex-grow: 1;
  156. .one_1 {
  157. border-bottom: 0.5vw solid var(--f9Color);
  158. swiper {
  159. height: 44vh !important;
  160. }
  161. .list {
  162. border-radius: 5px;
  163. .image {
  164. width: 100%;
  165. height: 100%;
  166. border-radius: 5px;
  167. background-color: #fff;
  168. }
  169. }
  170. }
  171. .one_2 {
  172. border-bottom: 0.5vw solid var(--f9Color);
  173. padding: 2vw;
  174. .money {
  175. font-size: 20px;
  176. padding: 0 1vw 0 0;
  177. color: var(--fF0Color);
  178. font-weight: bold;
  179. text {
  180. font-size: 14px;
  181. }
  182. }
  183. }
  184. .one_3 {
  185. display: flex;
  186. flex-wrap: wrap;
  187. padding: 1vw;
  188. border-bottom: 0.5vw solid var(--f9Color);
  189. }
  190. .one_4 {
  191. border-bottom: 0.5vw solid var(--f9Color);
  192. padding: 2vw;
  193. .name {
  194. width: 100%;
  195. overflow: hidden;
  196. text-overflow: ellipsis;
  197. word-break: break-all;
  198. font-size: 17px;
  199. font-weight: bold;
  200. margin: 0 0 2vw 0;
  201. }
  202. .brief {
  203. font-size: 14px;
  204. color: var(--f85Color);
  205. margin: 0 0 1vw 0;
  206. }
  207. }
  208. .one_5 {
  209. text-align: center;
  210. margin: 0 0 15vw 0;
  211. .list {
  212. .image {
  213. border-radius: 5px;
  214. background-color: #fff;
  215. }
  216. }
  217. }
  218. }
  219. .bottom {
  220. width: 100vw;
  221. position: fixed;
  222. bottom: 0;
  223. left: var(--window-left);
  224. right: var(--window-right);
  225. }
  226. }
  227. .scroll-view {
  228. position: absolute;
  229. top: 0;
  230. left: 0;
  231. right: 0;
  232. bottom: 0;
  233. .list-scroll-view {
  234. display: flex;
  235. flex-direction: column;
  236. }
  237. }
  238. </style>