mall.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <view :class="[AppTheme]" class="aall_box box">
  3. <!-- #ifdef APP-PLUS || MP-WEIXIN -->
  4. <u-navbar title="在线商城" :titleStyle="{color:'#ffffff'}" :bgColor="primary" :autoBack="false" :fixed="true"
  5. :placeholder="true" :height="45">
  6. <view class="u-nav-slot" slot="left"></view>
  7. </u-navbar>
  8. <!-- #endif -->
  9. <swiper v-if="gzList.length > 0" :interval="3000" :current="currentIndex1" :style="wrapper_style1"
  10. @change="changeSwiper1">
  11. <swiper-item v-for="(item, index) in gzList" :key="item.id" @click="navtopage(index)">
  12. <view :id="'contentwrap1' + index" style="width: 100%;">
  13. <image mode="widthFix" @load="setSwiperHeight('#contentwrap1' + index,1)" :src="item.ad_pic"
  14. style="width: 100%;"></image>
  15. </view>
  16. </swiper-item>
  17. </swiper>
  18. <view class="application">
  19. <view v-for="(item, index) in Classification" @click="$until.toUrl(item.url)" :key="index" class="app_to">
  20. <image class="a-img" :src="item.img" mode=""></image>
  21. <view class="p">{{item.modularname}}</view>
  22. </view>
  23. </view>
  24. <Ugoods2 ref="goodlist" :datas="{buynow_bg_color:$theme.primary}"></Ugoods2>
  25. <view class="NewProducts" v-show="gzList">
  26. <view class="center">
  27. <view class="line1 bg-primary"></view>
  28. <p class="subtitle text-primary">好产品上-农场商城</p>
  29. <view class="line2 bg-primary"></view>
  30. </view>
  31. <swiper v-if="gzList.length > 0" :interval="3000" :current="currentIndex2" :style="wrapper_style2"
  32. @change="changeSwiper2">
  33. <swiper-item v-for="(item, index) in gzList" :key="item.id" @click="navtopage(index)">
  34. <view :id="'contentwrap2' + index" style="width: 100%;">
  35. <image mode="widthFix" @load="setSwiperHeight('#contentwrap2' + index,2)" :src="item.ad_pic"
  36. style="width: 100%;"></image>
  37. </view>
  38. </swiper-item>
  39. </swiper>
  40. <view class="tag">
  41. <view class="tag-box text-primary border-primary " @click="$until.toUrl('/pagesE/pages/mall/list')">
  42. <u-icon name="shopping-cart-fill" :color="primary" size="50"></u-icon>
  43. <text>产品在线购物</text>
  44. </view>
  45. <view class="tag-box text-primary border-primary"
  46. @click="$until.toUrl('/pagesE/pages/broadcast/broadcast')">
  47. <u-icon name="camera-fill" :color="primary" size="50"></u-icon>
  48. <text>农场在线看</text>
  49. </view>
  50. <view class="tag-box text-primary border-primary"
  51. @click="$until.toUrl('/pages/index/adoplist/adoplist')" open-type="switchTab">
  52. <u-icon name="bag-fill" :color="primary" size="50"></u-icon>
  53. <text>农场产品认养</text>
  54. </view>
  55. </view>
  56. <view style="height: 20rpx;" />
  57. </view>
  58. <admyself :opshow="true"></admyself>
  59. <tabbar :primary="primary"></tabbar>
  60. <!-- 分享 -->
  61. <sharebox ref="sbox" v-if="sharedata" :data="sharedata"></sharebox>
  62. <view style="height: 120rpx;" />
  63. </view>
  64. </template>
  65. <!-- 商城 -->
  66. <script>
  67. import api from '@/api/mall/index.js';
  68. import api2 from '@/api/home/index.js';
  69. import homeApi from '@/api/home/index.js';
  70. import tabbar from '@/components/tabbar/tabbar.vue'
  71. import Ugoods2 from '@/components/ui-component/U_goods2/m/index.vue';
  72. export default {
  73. data() {
  74. return {
  75. primary: this.$theme.primary,
  76. shopList: [],
  77. settingFile: getApp().globalData.siteinfo,
  78. list_name: '',
  79. gzList: [],
  80. btList: [],
  81. Classification: [],
  82. sharedata: null,
  83. styles: {},
  84. currentIndex1: 0,
  85. currentIndex2: 0,
  86. swiperHeight1: 0,
  87. swiperHeight2: 0
  88. };
  89. },
  90. components: {
  91. tabbar,
  92. Ugoods2
  93. },
  94. computed: {
  95. /** 样式 */
  96. wrapper_style1() {
  97. const {
  98. swiperHeight,
  99. } = {
  100. swiperHeight: this.swiperHeight1
  101. };
  102. return `
  103. height:${swiperHeight}px;
  104. `;
  105. },
  106. /** 样式 */
  107. wrapper_style2() {
  108. const {
  109. swiperHeight,
  110. } = {
  111. swiperHeight: this.swiperHeight2
  112. };
  113. return `
  114. height:${swiperHeight}px;
  115. `;
  116. }
  117. },
  118. onPullDownRefresh() {
  119. let that = this
  120. that.shop();
  121. that.advertisement()
  122. that.$refs.goodlist.toBottom(1)
  123. },
  124. onReachBottom() {
  125. let that = this
  126. that.$refs.goodlist.toBottom()
  127. },
  128. onLoad(options) {
  129. let that = this;
  130. that.$bindid.getbindid(options, that.$store);
  131. that.shop();
  132. that.advertisement()
  133. that.$init_config(2, function(res) {
  134. if (that.$config) {
  135. that.sharedata = that.$config.sharedata
  136. }
  137. })
  138. },
  139. onShareAppMessage(res) {
  140. let that = this
  141. let data = {
  142. title: that.sharedata.title,
  143. imageUrl: that.sharedata.imageUrl,
  144. path: that.sharedata.path
  145. };
  146. return data;
  147. },
  148. onShareTimeline(res) {
  149. let that = this
  150. return {
  151. title: that.sharedata.title,
  152. imageUrl: that.sharedata.imageUrl,
  153. path: that.sharedata.path
  154. }
  155. },
  156. onShow: function() {
  157. let that = this;
  158. that.$init_config();
  159. if (that.primary == '' || that.primary != that.$theme.primary) {
  160. that.primary = that.$theme.primary;
  161. }
  162. this.shop();
  163. },
  164. methods: {
  165. shop() {
  166. api.shop().then(res => {
  167. if (res.status == 200) {
  168. this.shopList = res.data;
  169. this.list_name = res.data.shop.list_name
  170. this.Classification = res.data.modular1
  171. } else {
  172. this.$api.msg(res.msg);
  173. }
  174. });
  175. },
  176. //手动切换题目
  177. changeSwiper1(e) {
  178. let that = this;
  179. that.currentIndex1 = e.detail.current;
  180. //动态设置swiper的高度,使用nextTick延时设置
  181. that.$nextTick(() => {
  182. that.setSwiperHeight("#content-wrap1" + that.currentIndex1, 1);
  183. });
  184. },
  185. //手动切换题目
  186. changeSwiper2(e) {
  187. let that = this;
  188. that.currentIndex2 = e.detail.current;
  189. //动态设置swiper的高度,使用nextTick延时设置
  190. that.$nextTick(() => {
  191. that.setSwiperHeight("#content-wrap2" + that.currentIndex2, 2);
  192. });
  193. },
  194. //动态设置swiper的高度
  195. setSwiperHeight(element, type) {
  196. let query = uni.createSelectorQuery().in(this);
  197. query.select(element).boundingClientRect();
  198. query.exec((res) => {
  199. if (res && res[0]) {
  200. if (type == 1) {
  201. if (this.swiperHeight1 < res[0].height) {
  202. this.swiperHeight1 = res[0].height;
  203. }
  204. } else if (type == 2) {
  205. if (this.swiperHeight2 < res[0].height) {
  206. this.swiperHeight2 = res[0].height;
  207. }
  208. }
  209. }
  210. });
  211. },
  212. advertisement() {
  213. api.advertisement().then(res => {
  214. var list = res.data.filter(item => item.pid == 6);
  215. if (list.length) {
  216. this.gzList = list;
  217. } else {
  218. this.gzList = 0;
  219. }
  220. this.btList = this.gzList;
  221. })
  222. },
  223. navtopage(index) {
  224. homeApi.navtopage(this.gzList[index]);
  225. },
  226. navToDetailPage(id) {
  227. uni.navigateTo({
  228. url: `/pagesD/pages/product/product?id=${id}`
  229. });
  230. }
  231. }
  232. };
  233. </script>
  234. <style lang="scss">
  235. $color-fff: #fff;
  236. @mixin lineH($index) {
  237. height: $index;
  238. line-height: $index;
  239. }
  240. .tltile {
  241. font-size: 12px;
  242. overflow: hidden;
  243. white-space: nowrap;
  244. text-overflow: ellipsis;
  245. }
  246. .box {
  247. .carousel-item {
  248. width: 100%;
  249. image {
  250. width: 100% !important;
  251. height: 100% !important;
  252. }
  253. .s-img {
  254. width: 100%;
  255. height: 100%;
  256. }
  257. .swiper-dots {
  258. left: 45rpx;
  259. bottom: 40rpx;
  260. }
  261. }
  262. .application {
  263. background-color: #fff;
  264. display: flex;
  265. padding: 15rpx 20rpx 15rpx 20rpx;
  266. justify-content: space-around;
  267. align-items: center;
  268. .a-img {
  269. width: 90rpx;
  270. height: 90rpx;
  271. }
  272. .app_to {
  273. .p {
  274. margin: 0;
  275. padding-bottom: 10rpx;
  276. text-align: center;
  277. color: #383838;
  278. font-size: 24rpx;
  279. }
  280. }
  281. }
  282. .NewProducts {
  283. background-color: $color-fff;
  284. margin-top: 20rpx;
  285. .content {
  286. width: 100%;
  287. padding: 20rpx;
  288. box-sizing: border-box;
  289. min-height: 500rpx;
  290. .content_box {
  291. // border: 1rpx solid #efefef;
  292. box-shadow: $box-shadow;
  293. border-radius: 15rpx;
  294. width: 345rpx;
  295. padding-bottom: 10rpx;
  296. display: inline-block;
  297. &:nth-child(2n-1) {
  298. margin-bottom: 20rpx;
  299. margin-right: 20rpx;
  300. }
  301. .new-img {
  302. width: 100%;
  303. height: 355rpx;
  304. }
  305. .message {
  306. box-sizing: border-box;
  307. padding: 10rpx;
  308. .message_bot {
  309. height: 84rpx;
  310. margin-top: 20rpx;
  311. border-top: 0.5rpx solid #efefef;
  312. display: flex;
  313. justify-content: space-between;
  314. align-items: center;
  315. .f_left {
  316. margin-top: 10rpx;
  317. font-size: 24rpx;
  318. .color_org {
  319. margin-top: 10rpx;
  320. }
  321. .old_price {
  322. color: #999;
  323. margin-top: 10rpx;
  324. text-decoration: line-through;
  325. }
  326. }
  327. .f_right {
  328. width: 56rpx;
  329. height: 56rpx;
  330. margin-right: 10rpx;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .center {
  337. display: flex;
  338. justify-content: space-around;
  339. align-items: center;
  340. margin: 7.5rpx 0;
  341. line-height: 45px;
  342. .subtitle {
  343. // width: 180rpx;
  344. text-align: center;
  345. font-weight: 700;
  346. }
  347. .line1,
  348. .line2 {
  349. height: 2rpx;
  350. width: 30%;
  351. }
  352. }
  353. .tag {
  354. display: flex;
  355. justify-content: space-around;
  356. margin-top: 20rpx;
  357. .tag-box {
  358. width: 200rpx;
  359. height: 140rpx;
  360. border-width: 1rpx;
  361. border-style: solid;
  362. border-radius: 10rpx;
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. flex-direction: column;
  367. font-size: 24rpx;
  368. .tag-img {
  369. width: 60rpx;
  370. height: 60rpx;
  371. }
  372. }
  373. }
  374. }
  375. .stats_enabled {
  376. // height: 200rpx !important;
  377. }
  378. }
  379. </style>