hongbaokq.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="$t('index.hongbaokq')" titledetl=""></customNav>
  4. <view class="content contentInRowS" style="margin-top: 36rpx;height: 80rpx;">
  5. <view style="padding-left: 10rpx;" :class="cellindex==0?'cellsele':'cellNom'" @tap="cellSelect(0)">{{$t("hongbaokq.dailingqu")}}</view>
  6. <view :class="cellindex==1?'cellsele':'cellNom'" @tap="cellSelect(1)">{{$t("hongbaokq.daishiyong")}}</view>
  7. <view style="padding-right: 10rpx;" :class="cellindex==2?'cellsele':'cellNom'" @tap="cellSelect(2)">{{$t("hongbaokq.yiguoqi")}}</view>
  8. </view>
  9. <view v-if="cellindex==0">
  10. <view v-for="(item,index) in kaquanList" class="content" style="margin-top: 20rpx;">
  11. <view class="contentColumnC" style="padding-top: 16rpx;">
  12. <view class="contentInRowC">
  13. <text :class="item.type==0?'pingtName':'shangjiaName'">{{item.name}}</text>
  14. </view>
  15. <text style="color:#00A6FF;font-size: 26rpx;">{{$t('hongbaokq.youxiaoqi')}}{{item.validity}}{{$t('hongbaokq.tian')}}</text>
  16. </view>
  17. <view class="contentColumn">
  18. <text v-if="item.tiaojian==null" class="" style="font-size:28rpx;margin-left: 10rpx;">{{$t('hongbaokq.wumenkan')}}</text>
  19. <text v-if="item.tiaojian!=null" class="" style="font-size:28rpx;margin-left: 10rpx;">{{mankeyong(item.tiaojian)}}</text>
  20. <text class="" style="font-size:28rpx;margin-left: 10rpx;">{{getNote(item)}}</text>
  21. </view>
  22. <view class="contentColumnC" style="padding: 20rpx;" >
  23. <text :class="item.type==0?'pingtBt':'shjbt'" @tap="lijilingqu(index)">{{$t('hongbaokq.lingqu')}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. <view v-if="cellindex==1">
  28. <view v-for="(item,index) in kaquanList" class="content" style="margin-top: 20rpx;">
  29. <view class="contentColumnC" style="padding-top: 16rpx;">
  30. <view class="contentInRowC">
  31. <text :class="item.type==0?'pingtName':'shangjiaName'">{{item.name}}</text>
  32. </view>
  33. <text style="color:black;font-size: 26rpx;">{{$t('hongbaokq.youxiaoqi')}}{{changeDataframe(item.validity)}}</text>
  34. </view>
  35. <view class="contentColumn">
  36. <text v-if="item.tiaojian==null" class="" style="font-size:28rpx;margin-left: 10rpx;">{{$t('hongbaokq.wumenkan')}}</text>
  37. <text v-if="item.tiaojian!=null" class="" style="font-size:28rpx;margin-left: 10rpx;">{{mankeyong(item.tiaojian)}}</text>
  38. <text class="" style="font-size:28rpx;margin-left: 10rpx;">{{getNote(item)}}</text>
  39. </view>
  40. <view class="contentColumnC" style="padding: 20rpx;" >
  41. <text :class="item.type==0?'pingtBt':'shjbt'" @tap="lijishiyong">{{$t('hongbaokq.shiyong')}}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view v-if="cellindex==2">
  46. <view v-for="(item,index) in kaquanList" class="content" style="margin-top: 20rpx;">
  47. <view class="contentColumnC" style="padding-top: 16rpx;">
  48. <view class="contentInRowC">
  49. <text :class="item.type==0?'pingtName':'shangjiaName'">{{item.name}}</text>
  50. </view>
  51. <text style="color:#00A6FF;font-size: 26rpx;">{{$t('hongbaokq.youxiaoqi')}}{{changeDataframe(item.validity)}}</text>
  52. </view>
  53. <view class="contentColumn" style="padding: 10rpx;">
  54. <text v-if="item.tiaojian==null" class="" style="font-size:28rpx;margin-left: 10rpx;">{{$t('hongbaokq.wumenkan')}}</text>
  55. <text v-if="item.tiaojian!=null" class="" style="font-size:28rpx;margin-left: 10rpx;">{{mankeyong(item.tiaojian)}}</text>
  56. <text class="" style="font-size:28rpx;margin-left: 10rpx;">{{getNote(item)}}</text>
  57. </view>
  58. </view>
  59. </view>
  60. <view style="height: 100rpx;"></view>
  61. </view>
  62. </template>
  63. <script>
  64. import api from "@/pages/api/api.js"
  65. export default {
  66. data() {
  67. return {
  68. cellindex:0,
  69. kaquanList:[],
  70. page:1
  71. }
  72. },
  73. onShow() {
  74. this.cellindex=0;
  75. this.getdailingHongbaokq(0);
  76. },
  77. methods: {
  78. cellSelect(index){
  79. this.page=1;
  80. if(index!=this.cellindex){
  81. this.kaquanList = [];
  82. }
  83. this.cellindex = index;
  84. if(index==0){
  85. this.getdailingHongbaokq(index);
  86. }
  87. else if(index==1){
  88. this.getHongbaokq(index);
  89. }
  90. else if(index==2){
  91. this.getHongbaokq(index);
  92. }
  93. },
  94. changeDataframe(date){
  95. if(date.length==10){
  96. var st2 = date.substr(8,2);
  97. st2=st2+'-'+date.substr(5,2);
  98. st2=st2+'-'+date.substr(0,4);
  99. return st2;
  100. }
  101. return date;
  102. },
  103. getNote(obj){
  104. var str='';
  105. if(obj.yhfangs==1&&obj.yhnum>1){//优惠方式:1 运费,2 订单 ,3 商品
  106. str= this.$t('hongbaokq.yunfeiyh');
  107. }
  108. if(obj.yhfangs==1&&obj.yhnum<1&&obj.yhnum>0){//优惠方式:1 运费,2 订单 ,3 商品
  109. str= this.$t('hongbaokq.yunfeizk');
  110. }
  111. if(obj.yhfangs==1&&obj.yhnum==0){//优惠方式:1 运费,2 订单 ,3 商品
  112. str= this.$t('hongbaokq.yunfeiquanm');
  113. }
  114. if(obj.yhfangs==2&&obj.yhnum>1){
  115. str= this.$t('hongbaokq.dingdanyh');
  116. }
  117. if(obj.yhfangs==2&&obj.yhnum<1){
  118. str= this.$t('hongbaokq.dingdanzk');
  119. }
  120. if(obj.yhfangs==3&&obj.yhnum>1){
  121. str= this.$t('hongbaokq.shangpinyh');
  122. }
  123. if(obj.yhfangs==3&&obj.yhnum<1){
  124. str= this.$t('hongbaokq.shangpinzk');
  125. }
  126. if(obj.yhnum!=0){
  127. str=str+' '+obj.yhnum +this.$t("locale.huobidw");
  128. }
  129. return str;
  130. },
  131. mankeyong(jiner){
  132. var str = this.$t('hongbaokq.mankeyong')
  133. str = str.replace('x',jiner);
  134. return str;
  135. },
  136. lijilingqu(index){
  137. if(this.kaquanList.length>=index){
  138. var obj = this.kaquanList[index];
  139. this.lingqukaquan(obj.id);
  140. }
  141. },
  142. lijishiyong(){
  143. uni.navigateTo({
  144. url:'/pages/OrderList/buy/gouwuche'
  145. })
  146. },
  147. getdailingHongbaokq(index){
  148. if(index==0){
  149. api('userUnclaimedList',{
  150. pageNum:''+this.page,
  151. pageSize:'20',
  152. },res=>{
  153. uni.stopPullDownRefresh();
  154. console.log('-----------',res)
  155. if(res.data.code==200){
  156. if(this.page>1){
  157. if(res.data.rows&&res.data.rows.length>0){
  158. var temp = this.kaquanList;
  159. for(var i=0;i<res.data.rows.length;i++){
  160. temp.push(res.data.rows[i]);
  161. }
  162. this.kaquanList=temp;
  163. }
  164. }
  165. else{
  166. this.kaquanList=res.data.rows;
  167. }
  168. }
  169. },failc=>{
  170. uni.stopPullDownRefresh();
  171. console.log('getadvertis----',failc)
  172. })
  173. }
  174. },
  175. getHongbaokq(index){
  176. var listType='';
  177. if(index==1){
  178. listType='1';
  179. }
  180. else if(index==2){
  181. listType='2';
  182. }
  183. api('userQuanyilist',{
  184. pageNum:this.page,
  185. pageSize:'20',
  186. listType:listType
  187. },res=>{
  188. uni.stopPullDownRefresh();
  189. console.log('-----------',res)
  190. if(res.data.code==200){
  191. if(this.page>1){
  192. if(res.data.data.records&&res.data.data.records.length>0){
  193. var temp = this.kaquanList;
  194. for(var i=0;i<res.data.data.records.length;i++){
  195. temp.push(res.data.data.records[i]);
  196. }
  197. this.kaquanList=temp;
  198. }
  199. }
  200. else{
  201. this.kaquanList=res.data.data.records;
  202. }
  203. }
  204. },failc=>{
  205. uni.stopPullDownRefresh();
  206. //console.log('getadvertis----',failc)
  207. })
  208. },
  209. lingqukaquan(quanyiId){
  210. api('userQuanyireceive',{
  211. quanyiId:quanyiId,
  212. num:1
  213. },r=>{
  214. console.log('-----------',r)
  215. if(r.data.code==200){
  216. this.page=1;
  217. this.getdailingHongbaokq(0);
  218. uni.showToast({
  219. title:this.$t('hongbaokq.lingqucg'),
  220. icon: 'none',
  221. duration: 2500
  222. })
  223. }
  224. else{
  225. uni.showToast({
  226. title:this.$t('hongbaokq.lingqushib'),
  227. icon: 'none',
  228. duration: 2500
  229. })
  230. }
  231. },failc=>{
  232. uni.showToast({
  233. title:this.$t('hongbaokq.lingqushib'),
  234. icon: 'none',
  235. duration: 2500
  236. })
  237. //console.log('getadvertis----',failc)
  238. })
  239. },
  240. },
  241. /**
  242. * 下拉刷新回调函数
  243. */
  244. onPullDownRefresh() {
  245. console.log('onPullDownRefresh')
  246. this.page=1;
  247. if(this.cellindex==0){
  248. this.getdailingHongbaokq(this.cellindex);
  249. }
  250. else if(this.cellindex==1){
  251. this.getHongbaokq(this.cellindex);
  252. }
  253. else if(this.cellindex==2){
  254. this.getHongbaokq(this.cellindex);
  255. }
  256. },
  257. /**
  258. * 上拉加载回调函数
  259. */
  260. onReachBottom() {
  261. console.log('onReachBottom')
  262. this.page=this.page+1;
  263. if(this.cellindex==0){
  264. this.getdailingHongbaokq(this.cellindex);
  265. }
  266. else if(this.cellindex==1){
  267. this.getHongbaokq(this.cellindex);
  268. }
  269. else if(this.cellindex==2){
  270. this.getHongbaokq(this.cellindex);
  271. }
  272. },
  273. }
  274. </script>
  275. <style lang="scss">
  276. page{
  277. background-color: #F2F3F7;
  278. }
  279. .cellsele{
  280. color: #00A6FF;
  281. font-size: 30rpx;
  282. }
  283. .cellNom{
  284. color: black;
  285. font-size: 26rpx;
  286. }
  287. .pingtName{
  288. color: #00A6FF;
  289. font-size: 32rpx;
  290. }
  291. .shangjiaName{
  292. color: green;
  293. font-size: 32rpx;
  294. }
  295. .pingtBt{
  296. width: 50%;
  297. height: 50rpx;
  298. line-height: 60rpx;
  299. border-radius: 20rpx;
  300. border: solid #00A6FF;
  301. border-width: 0px 0px 6rpx 0px;
  302. text-align: center;
  303. justify-content: center;
  304. background-color: #00A6FF;
  305. color: white;
  306. box-shadow: 0rpx 0rpx 10rpx 0rpx #00A6FF;
  307. }
  308. .shjbt{
  309. width: 50%;
  310. height: 50rpx;
  311. line-height: 60rpx;
  312. border-radius: 20rpx;
  313. border: solid green;
  314. border-width: 0px 0px 6rpx 0px;
  315. text-align: center;
  316. justify-content: center;
  317. background-color: green;
  318. color: white;
  319. box-shadow: 0rpx 0rpx 10rpx 0rpx green;
  320. }
  321. </style>