dt_special.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="dt-page" >
  3. <image v-for="(img,index) in special.imgs" :src="img" mode="widthFix" :key="index" style="width: 100vw;display: block;"/>
  4. <view v-for="(item, index) in specialTags" :key="index" style="position: relative;">
  5. <image v-if="item.isBgImg" :src="item.path1" mode="widthFix" style="width: 100vw;display: block;"></image>
  6. <view style="position: absolute;top: 0;left: 0;right: 0;display: flex;flex-direction: column;align-items: center;">
  7. <view v-if="index==0" style="color: #fde9ac;font-size: 40upx;font-weight: bold;letter-spacing: 10upx;margin: 50upx 0 160upx;">{{item.name}}</view>
  8. <view v-else style="color: #fde9ac;font-size: 40upx;font-weight: bold;letter-spacing: 10upx;margin: 50upx 0;">{{item.name}}</view>
  9. <view style="display: flex;flex-wrap: wrap;">
  10. <view v-if="childIndex==0&&childIndex<5" v-for="(child,childIndex) in item.products" :key="childIndex" @tap="jumpGoodsDes(child.id||child.productId)" style="width: 100vw;margin-bottom: 20upx;position: relative;">
  11. <image v-if="index==0" src="http://139.9.103.171:1888/img/image/festival_goods_bg3.png" style="width: 670upx;margin: 0 40upx;" mode="widthFix"></image>
  12. <image v-else src="http://139.9.103.171:1888/img/image/festival_goods_bg2.png" style="width: 670upx;margin: 0 40upx;" mode="widthFix"></image>
  13. <view style="position: absolute;top: 20upx;bottom:20upx;left: 70upx;right:70upx;display: flex;align-items: center;overflow: hidden;">
  14. <view style="width: 253upx;height: 253upx;">
  15. <image :src="child.thumbnail||child.img|| 'http://139.9.103.171:1888/img/image/goods_def.png'" style="width: 253upx;height: 253upx;display: block;"></image>
  16. </view>
  17. <view :style="{color: index==0?'#dc131b':'#fde9ac'}" style="margin-left: 20upx;font-size: 20upx;width: 350upx;">
  18. <view class="dt-text-row-one" style="font-size: 30upx;margin-top: 20upx;">{{child.name}}</view>
  19. <view style="margin: 5upx 0;overflow: hidden;white-space: nowrap;">-------------------------------------------------</view>
  20. <view class="dt-text-row-one">{{child.caption}}</view>
  21. <view style="position: relative;">
  22. <image src="http://139.9.103.171:1888/img/image/festival_goods_boom.png" style="margin-top: 10upx;width: 280upx;display: block;" mode="widthFix"></image>
  23. <view style="text-decoration: line-through;position: absolute;top: 5upx;left: 0;">原价¥{{child.marketPrice}}</view>
  24. </view>
  25. <view style="display: flex;height: 35upx;align-items: flex-end;">
  26. <view>惊喜价</view>
  27. <view style="font-size: 30upx;margin-bottom: -6upx;">¥</view>
  28. <view style="font-size: 40upx;font-weight: bold;margin-bottom: -8upx;">{{child.price}}</view>
  29. <view v-if="index==0" style="background-color: #dc131b;color: #fde9ac;border-radius: 25px;padding: 4upx;margin-left: 20upx;font-size: 16upx;">立即购买>></view>
  30. <view v-else style="background-color: #fde9ac;color: #183f6a;border-radius: 25px;padding: 4upx;margin-left: 20upx;font-size: 16upx;">立即购买>></view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view v-if="childIndex!=0&&childIndex<5" v-for="(child,childIndex) in item.products" :key="childIndex" @tap="jumpGoodsDes(child.id||child.productId)" style="width: 306upx;margin-left: 45upx;margin-bottom: 20upx;position: relative;">
  36. <image src="http://139.9.103.171:1888/img/image/festival_goods_bg.png" style="width: 100%;display: block;" mode="widthFix"></image>
  37. <view style="position: absolute;top: 20upx;left: 15upx;right: 8upx;bottom:10upx;border-radius: 14upx;overflow: hidden;">
  38. <view style="width: 283upx;height: 283upx;">
  39. <image :src="child.thumbnail||child.img|| 'http://139.9.103.171:1888/img/image/goods_def.png'" style="width: 283upx;height: 283upx;"></image>
  40. <view class="goods_sell_out_tip" v-if="false">补货中</view>
  41. </view>
  42. <view style="background-color: #c01e1c;height: 80upx;padding: 10upx;color:#fde9ac;">
  43. <view class="dt-text-row-one" style="font-size: 25upx;">{{child.name}}</view>
  44. <view style="display: flex;font-size: 20upx;height: 45upx;display: flex;align-items: flex-end;">
  45. <view style="text-decoration: line-through;">原价¥{{child.marketPrice}}</view>
  46. <view style="margin-left: 20upx;">惊喜价¥</view>
  47. <view style="font-size: 30upx;">{{child.price}}</view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import DtEmpty from '../comps/dt_empty.vue'
  59. import DtGoodsList from '../comps/dt_goods_list.vue'
  60. import DtNoMore from '../comps/dt_no_more.vue'
  61. export default {
  62. components: {
  63. DtGoodsList,
  64. DtEmpty,
  65. DtNoMore
  66. },
  67. data() {
  68. return {
  69. bgColor:'transparent',
  70. specialId:'',
  71. specialTags: [], //会场标签
  72. special: {},//会场
  73. url:'',
  74. params:{},
  75. selectIndex:0,
  76. theme:0,
  77. coupons:[],
  78. winHeight:''
  79. };
  80. },
  81. computed: {
  82. calcHeight() {
  83. return "height:" + this.winHeight + "px;";
  84. },
  85. swiperHeight() {
  86. return "height:" + this.winHeight + "px;";
  87. }
  88. },
  89. onReady() {
  90. //swiper高度自适应
  91. this.getElementHeight('.swiper-wrapper')
  92. },
  93. methods:{
  94. jumpGoodsDes(id) {
  95. console.log(id);
  96. uni.navigateTo({
  97. url: "/pagesM/pages/goods_des?id=" + id
  98. })
  99. },
  100. imgload(){
  101. this.getElementHeight('.swiper-wrapper')
  102. },
  103. getElementHeight(element) {
  104. let windowHeight = 0;
  105. uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
  106. success(res) { //成功回调函数
  107. windowHeight=res.windowHeight //windoHeight为窗口高度,主要使用的是这个
  108. }
  109. });
  110. setTimeout(()=>{
  111. // let query = uni.createSelectorQuery().in(this);
  112. // query.select(element).boundingClientRect();
  113. // query.exec((res) => {
  114. // if (!res) {//如果没获取到,再调一次
  115. // this.getElementHeight();
  116. // }else {
  117. // this.swiperHeight = (windowHeight-res[0][0].top)+'px';
  118. // console.log(res[0][0].top,res)
  119. // }
  120. // })
  121. const query = uni.createSelectorQuery().in(this);
  122. query.selectAll(element).boundingClientRect();
  123. query.exec((res) => {
  124. if (!res) {//如果没获取到,再调一次
  125. this.getElementHeight();
  126. }else {
  127. this.winHeight = windowHeight - res[0][0].top;
  128. }
  129. })
  130. },20)
  131. },
  132. onReachLower(ev) {
  133. this.onReachBottomPage();
  134. },
  135. onLoadPage(options) {
  136. uni.setNavigationBarTitle({
  137. title:options.title
  138. });
  139. this.theme = options.style;
  140. if(options.style==0){
  141. uni.setNavigationBarColor({
  142. frontColor: '#ffffff',
  143. backgroundColor:'#dd524d'
  144. })
  145. }
  146. this.memberId = this.$auth.getMemberId();
  147. this.url = options.url;
  148. let strLength = this.findIndexOf(this.url);
  149. this.params['theme'] = this.url.substring(strLength[strLength.length-3]+1,(strLength[strLength.length-2]));
  150. this.params['specialAttributeId'] = this.url.substring((strLength[strLength.length-2])+1,(strLength[strLength.length-1]));
  151. console.log(this.params)
  152. this.getSpecial();
  153. // 初始化高度
  154. // let res = uni.getSystemInfoSync();
  155. // let clientHeight = res.windowHeight;
  156. // let clientWidth = res.windowWidth;
  157. // let upxR = 750 / clientWidth;
  158. // let calc = clientHeight * upxR - 110;
  159. // let height = uni.upx2px(calc);
  160. // this.winHeight = height;
  161. },
  162. findIndexOf(str) {
  163. let strArr=[];
  164. for(let i =0;i<str.length;i++){
  165. if(str[i]=='/'){
  166. strArr.push(i);
  167. }
  168. }
  169. return strArr;
  170. },
  171. // async getCoupons() {
  172. // let resp = await this.$api.getCoupons({
  173. // memberId: this.memberId
  174. // });
  175. // return resp
  176. // },
  177. async getSpecial() {
  178. let resp = await this.$api.getSpecial({
  179. _isShowLoading:true,
  180. memberId: this.memberId,
  181. sessionId:null,
  182. specialAttributeId:this.params.specialAttributeId,
  183. theme:this.params.theme
  184. });
  185. this.special = resp.specialAttribute;
  186. this.specialTags = resp.specialTags;
  187. this.coupons = resp.coupons;
  188. if(this.specialTags[0].products.length>0){
  189. this.emptyType = 0;
  190. }else{
  191. this.emptyType = 1;
  192. }
  193. },
  194. // async loadProducts(specialTagId){
  195. // let hasValue=false,index=null;
  196. // for (var i = 0,j=this.specialTags.length; i < j; i++) {
  197. // if(this.specialTags[i].id==specialTagId){
  198. // hasValue=this.specialTags[i].products.length>0;
  199. // index=i;
  200. // }
  201. // }
  202. // if(!hasValue){
  203. // let resp = await this.$api.getProducts({
  204. // specialId:this.params.specialAttributeId,
  205. // specialTagId:specialTagId,
  206. // });
  207. // this.specialTags[index].products=resp;
  208. // }
  209. // },
  210. changetabs(index){
  211. this.selectIndex = index;
  212. // this.isNoMore = false
  213. // this.emptyType = -1
  214. // this.pageIndex = 0;
  215. // this.dataList.length = 0
  216. if(this.specialTags[index].products.length>0){
  217. this.emptyType = 0;
  218. }else{
  219. this.emptyType = 1;
  220. }
  221. // let specialTagId = this.specialTags[index]['id'];
  222. // this.loadProducts(specialTagId);
  223. },
  224. onSwiperChange(e){
  225. this.selectIndex = e.detail.current;
  226. if(this.specialTags[e.detail.current].products.length>0){
  227. this.emptyType = 0;
  228. }else{
  229. this.emptyType = 1;
  230. }
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="scss">
  236. .menu_scroll{
  237. padding: 0 20upx;
  238. white-space: nowrap;
  239. height: 70upx;
  240. display: flex;
  241. align-items: center;
  242. .menu_item{
  243. text-align: center;
  244. font-size: 28upx;
  245. font-weight: bold;
  246. flex:1;
  247. text-align: center;
  248. }
  249. .menu_item02{
  250. text-align: center;
  251. font-size: 28upx;
  252. font-weight: bold;
  253. margin-right: 20upx;
  254. text-align: center;
  255. }
  256. .menu_item_active{
  257. color: $dt-color-primary;
  258. }
  259. .menu_item_line_active{
  260. background-color: #fff;
  261. }
  262. }
  263. </style>