promotion_detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view class="dt-page">
  3. <view v-show="theme==0"
  4. style="
  5. background-color: #dd524d;
  6. position: absolute;
  7. top: 0;
  8. left: 0;
  9. right: 0;
  10. height: 130upx;
  11. border-bottom-left-radius: 10%;
  12. border-bottom-right-radius: 10%;">
  13. </view>
  14. <view v-show="theme==0" style="margin: 0 20upx;position: relative; ">
  15. <image v-for="(item,index) in special.imgs" :key="index" :src="item" mode="widthFix" @load="imgload" style="width: 100%;border-radius: 20upx;position: relative;margin-top: 50upx; "></image>
  16. </view>
  17. <image v-show="theme!=0" v-for="(item,index) in special.imgs" :key="index" :src="item" mode="widthFix" @onload="imgload" style="width: 100%;"></image>
  18. <scroll-view scroll-x="true">
  19. <view class="menu_scroll" >
  20. <view
  21. v-show="specialTags.length>4"
  22. v-for="(item,index) in specialTags"
  23. :key="index"
  24. @tap="changetabs(index)"
  25. :class="index==selectIndex?'menu_item_active':''"
  26. :style="special.imgs?'':'color:#fff'"
  27. class="menu_item02">
  28. <view>
  29. {{item.name}}
  30. </view>
  31. <view
  32. v-show="!special.imgs"
  33. :class="index==selectIndex?'menu_item_line_active':''"
  34. style="height: 4upx;width: 60upx;margin: 10upx auto 0;">
  35. </view>
  36. </view>
  37. <view
  38. v-show="specialTags.length<5"
  39. v-for="(item,index) in specialTags"
  40. :key="index"
  41. @tap="changetabs(index)"
  42. :class="index==selectIndex?'menu_item_active':''"
  43. :style="special.imgs?'':'color:#fff'"
  44. class="menu_item">
  45. <view>
  46. {{item.name}}
  47. </view>
  48. <view
  49. v-show="!special.imgs"
  50. :class="index==selectIndex?'menu_item_line_active':''"
  51. style="height: 4upx;width: 60upx;margin: 10upx auto 0;">
  52. </view>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. <view v-show="theme!=0" v-for="(item,index) in specialTags" :key="index"
  57. style="margin: 0 20upx;
  58. height:74upx;
  59. font-size: 32upx;
  60. color: #DB4444;
  61. font-weight: 800;
  62. line-height: 74upx;
  63. text-align: center;
  64. background:rgba(255,230,230,1);
  65. border:2upx solid rgba(219,68,68,1);
  66. border-radius:25px;">{{item.name}}</view>
  67. <view class="swiper-wrapper">
  68. <swiper :style="swiperHeight" duration="300" :current="selectIndex" @change="onSwiperChange">
  69. <swiper-item v-for="(tItem, tIdx) in specialTags" :key="tIdx" >
  70. <scroll-view @scrolltolower="onReachLower" scroll-y="true" style="height: 100%;">
  71. <block v-show="selectIndex==tIdx">
  72. <view v-show="emptyType==0" class="content-wrap">
  73. <DtGoodsList :dataList="tItem.products" :bgColor="bgColor" />
  74. <DtNoMore v-if="isNoMore" />
  75. </view>
  76. <view style="margin-top: 100upx;">
  77. <DtEmpty :type="emptyType"/>
  78. </view>
  79. </block>
  80. </scroll-view>
  81. </swiper-item>
  82. </swiper>
  83. </view>
  84. <view v-if="coupons.length>0&&couponShow" class="coupon_mengban">
  85. <view class="coupon" @tap.stop="tapDrawCoupon">
  86. <image src="http://139.9.103.171:1888/img/image/promotion_coupon.png" mode="widthFix" style="width: 650upx;height: 680upx;" ></image>
  87. <image class="ic_off" src="http://139.9.103.171:1888/img/image/ic_coupon_off.png" mode="widthFix" @tap.stop="close_coupon"></image>
  88. <view class="scroll">
  89. <view v-if="!item.isReceive&&index<3" v-for="(item, index) in coupons" :key="index" style="position: relative;margin-bottom: 10upx;">
  90. <image src="http://139.9.103.171:1888/img/image/promotion_coupon_item.png" mode="widthFix"></image>
  91. <view style="padding: 0 20upx;position: absolute;top:0;bottom: 0;left: 0;right:0;display: flex;align-items: center;color: #ff4300;">
  92. <view style="display: flex;align-items: flex-end;width: 180upx;">
  93. <view style="font-size: 30upx;margin-bottom: 5upx;font-weight: bold;">¥</view>
  94. <view style="font-size: 60upx;font-weight: bold;">{{item.amt}}</view>
  95. </view>
  96. <view>
  97. <view style="font-size: 28upx;margin-bottom: 10upx;">{{item.name}}</view>
  98. <view style="font-size: 17upx;color: #999999;">此券仅在新邻社区小程序商城使用</view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import DtEmpty from './dt_empty.vue'
  109. import DtGoodsList from './dt_goods_list.vue'
  110. import DtNoMore from './dt_no_more.vue'
  111. export default {
  112. components: {
  113. DtGoodsList,
  114. DtEmpty,
  115. DtNoMore
  116. },
  117. data() {
  118. return {
  119. bgColor:'transparent',
  120. specialId:'',
  121. specialTags: [], //会场标签
  122. special: {},//会场
  123. url:'',
  124. params:{},
  125. selectIndex:0,
  126. theme:0,
  127. coupons:[],
  128. winHeight:'',
  129. couponShow:false
  130. };
  131. },
  132. computed: {
  133. calcHeight() {
  134. return "height:" + this.winHeight + "px;";
  135. },
  136. swiperHeight() {
  137. return "height:" + this.winHeight + "px;";
  138. }
  139. },
  140. onReady() {
  141. //swiper高度自适应
  142. this.getElementHeight('.swiper-wrapper')
  143. },
  144. methods:{
  145. close_coupon(){
  146. this.couponShow = false;
  147. },
  148. imgload(){
  149. this.getElementHeight('.swiper-wrapper')
  150. },
  151. getElementHeight(element) {
  152. let windowHeight = 0;
  153. uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
  154. success(res) { //成功回调函数
  155. windowHeight=res.windowHeight //windoHeight为窗口高度,主要使用的是这个
  156. }
  157. });
  158. setTimeout(()=>{
  159. // let query = uni.createSelectorQuery().in(this);
  160. // query.select(element).boundingClientRect();
  161. // query.exec((res) => {
  162. // if (!res) {//如果没获取到,再调一次
  163. // this.getElementHeight();
  164. // }else {
  165. // this.swiperHeight = (windowHeight-res[0][0].top)+'px';
  166. // console.log(res[0][0].top,res)
  167. // }
  168. // })
  169. const query = uni.createSelectorQuery().in(this);
  170. query.selectAll(element).boundingClientRect();
  171. query.exec((res) => {
  172. if (!res) {//如果没获取到,再调一次
  173. this.getElementHeight();
  174. }else {
  175. this.winHeight = windowHeight - res[0][0].top;
  176. }
  177. })
  178. },20)
  179. },
  180. onReachLower(ev) {
  181. this.onReachBottomPage();
  182. },
  183. onLoadPage(options) {
  184. uni.setNavigationBarTitle({
  185. title:options.title
  186. });
  187. this.theme = options.style;
  188. if(options.style==0){
  189. uni.setNavigationBarColor({
  190. frontColor: '#ffffff',
  191. backgroundColor:'#dd524d'
  192. })
  193. }
  194. this.memberId = this.$auth.getMemberId();
  195. this.url = options.url;
  196. let strLength = this.findIndexOf(this.url);
  197. this.params['theme'] = this.url.substring(strLength[strLength.length-3]+1,(strLength[strLength.length-2]));
  198. this.params['specialAttributeId'] = this.url.substring((strLength[strLength.length-2])+1,(strLength[strLength.length-1]));
  199. console.log(this.params)
  200. this.getSpecial();
  201. // 初始化高度
  202. // let res = uni.getSystemInfoSync();
  203. // let clientHeight = res.windowHeight;
  204. // let clientWidth = res.windowWidth;
  205. // let upxR = 750 / clientWidth;
  206. // let calc = clientHeight * upxR - 110;
  207. // let height = uni.upx2px(calc);
  208. // this.winHeight = height;
  209. },
  210. findIndexOf(str) {
  211. let strArr=[];
  212. for(let i =0;i<str.length;i++){
  213. if(str[i]=='/'){
  214. strArr.push(i);
  215. }
  216. }
  217. return strArr;
  218. },
  219. tapDrawCoupon(){
  220. let list = []
  221. this.coupons.map((item,index)=>{
  222. list.push(this.getCoupons(item))
  223. })
  224. Promise.race(list).then((resList) => {
  225. console.log(255, resList)
  226. }).catch(err => {
  227. consle.log(err)
  228. }).finally(() => {
  229. this.$dialog.toast('领取成功')
  230. this.couponShow = false
  231. })
  232. },
  233. async getCoupons(item) {
  234. // let resp = await this.$api.getCoupons({
  235. // memberId: this.memberId,
  236. // id:item.id
  237. // });
  238. this.isLogin = this.$auth.isAuth;
  239. if (!this.$auth.isAuth) {
  240. this.$refs.dialogLogin.show();
  241. return;
  242. }
  243. let member = this.$auth.getMemberInfo();
  244. if(member == null){
  245. this.$refs.dialogLogin.show();
  246. return;
  247. }
  248. if(!member.isNewMember){
  249. this.$dialog.toast('仅新人可领取');
  250. return;
  251. }
  252. if(item.isReceive){
  253. this.$dialog.toast('已领取');
  254. return;
  255. }
  256. let resp = await this.$api.couponExchange({memberId:this.$auth.getMemberId(),couponId:item.id,_isShowLoading: true,})
  257. return resp
  258. },
  259. async getSpecial() {
  260. let resp = await this.$api.getSpecial({
  261. _isShowLoading:true,
  262. memberId: this.memberId,
  263. sessionId:null,
  264. specialAttributeId:this.params.specialAttributeId,
  265. theme:this.params.theme
  266. });
  267. this.special = resp.specialAttribute;
  268. this.specialTags = resp.specialTags;
  269. let respCoupons = await this.$api.getNewCoupons({})
  270. this.coupons = respCoupons;
  271. let member = this.$auth.getMemberInfo();
  272. if(respCoupons.length>0){
  273. respCoupons.map((item)=>{
  274. if(!item.isReceive&&member.isNewMember){
  275. this.couponShow = true
  276. }
  277. })
  278. }
  279. if(this.specialTags[0].products.length>0){
  280. this.emptyType = 0;
  281. }else{
  282. this.emptyType = 1;
  283. }
  284. },
  285. // async loadProducts(specialTagId){
  286. // let hasValue=false,index=null;
  287. // for (var i = 0,j=this.specialTags.length; i < j; i++) {
  288. // if(this.specialTags[i].id==specialTagId){
  289. // hasValue=this.specialTags[i].products.length>0;
  290. // index=i;
  291. // }
  292. // }
  293. // if(!hasValue){
  294. // let resp = await this.$api.getProducts({
  295. // specialId:this.params.specialAttributeId,
  296. // specialTagId:specialTagId,
  297. // });
  298. // this.specialTags[index].products=resp;
  299. // }
  300. // },
  301. changetabs(index){
  302. this.selectIndex = index;
  303. // this.isNoMore = false
  304. // this.emptyType = -1
  305. // this.pageIndex = 0;
  306. // this.dataList.length = 0
  307. if(this.specialTags[index].products.length>0){
  308. this.emptyType = 0;
  309. }else{
  310. this.emptyType = 1;
  311. }
  312. // let specialTagId = this.specialTags[index]['id'];
  313. // this.loadProducts(specialTagId);
  314. },
  315. onSwiperChange(e){
  316. this.selectIndex = e.detail.current;
  317. if(this.specialTags[e.detail.current].products.length>0){
  318. this.emptyType = 0;
  319. }else{
  320. this.emptyType = 1;
  321. }
  322. }
  323. }
  324. }
  325. </script>
  326. <style lang="scss">
  327. .menu_scroll{
  328. padding: 0 20upx;
  329. white-space: nowrap;
  330. height: 70upx;
  331. display: flex;
  332. align-items: center;
  333. .menu_item{
  334. text-align: center;
  335. font-size: 28upx;
  336. font-weight: bold;
  337. flex:1;
  338. text-align: center;
  339. }
  340. .menu_item02{
  341. text-align: center;
  342. font-size: 28upx;
  343. font-weight: bold;
  344. margin-right: 20upx;
  345. text-align: center;
  346. }
  347. .menu_item_active{
  348. color: $dt-color-primary;
  349. }
  350. .menu_item_line_active{
  351. background-color: #fff;
  352. }
  353. }
  354. .coupon_mengban{
  355. transition: all 3s ease;
  356. position: fixed;
  357. top: 0;
  358. bottom: 0;
  359. right:0;
  360. left:0;
  361. background-color: rgba(0,0,0,0.7);
  362. z-index: 1;
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. z-index: 9;
  367. .coupon{
  368. width: 650upx;
  369. position: relative;
  370. display: flex;
  371. flex-direction: column;
  372. justify-content: center;
  373. align-items: center;
  374. .scroll {
  375. width: 485upx;
  376. height: 320upx;
  377. bottom: 20upx;
  378. position: absolute;
  379. image{
  380. width: 485upx;
  381. }
  382. }
  383. }
  384. .ic_off{
  385. width: 50upx;
  386. height: 50upx;
  387. position: absolute;
  388. bottom: -100upx;
  389. z-index:10
  390. }
  391. }
  392. </style>