index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view>
  3. <view :class="'top-fixed' + (skinNotColor ? ' not-color' : '')" :style="'height: ' + systems.barHeight + 'rpx;'">
  4. <view :class="'bgcolor' + (isTop == 1 ? ' opacity' : '')" :style="'height:' + systems.barHeight + 'rpx'"></view>
  5. <view class="top-fixed-c" :style="'height: ' + systems.navigationHeight + 'rpx;margin-top:' + systems.ktxStatusHeight + 'rpx;'">
  6. <navigator url="" hover-class="none" open-type="navigateBack" class="back"><image :src="picUrlss + 'back_white.png'"></image></navigator>
  7. <view class="top-title tover" :style="'line-height: ' + systems.navigationHeight + 'rpx;'">获取积分</view>
  8. </view>
  9. </view>
  10. <view class="top" :style="'padding-top: ' + systems.barHeight + 'rpx;'">
  11. <image src="../static/integralShop/images/task_bg.png" class="task-bg"></image>
  12. <view class="top-c ddflex">
  13. <view class="jifen fflex">
  14. <text>我的积分</text>
  15. {{ integralData.userIntegral }}
  16. </view>
  17. <view class="top-btn ddflex" @click="jumpUrl('/integralshop/index/index')">
  18. <image src="../static/integralShop/images/jfico3.png"></image>
  19. 积分商城
  20. </view>
  21. </view>
  22. </view>
  23. <view class="date" v-if="taskSign && taskSign.response && taskSign.response.length > 0">
  24. <view class="date-list ddflex">
  25. <view :class="'li' + (item.isSign ? ' end' : item.sameDay ? ' ing' : '')" v-for="(item, index) in taskSign.response" :key="index">
  26. <view class="li-jifen ddflex" v-if="item.isSign"><image src="../static/integralShop/images/qd_gou.png" class="yiqian"></image></view>
  27. <view class="li-jifen ddflex" v-else>+{{ item.integral }}</view>
  28. <view class="day">{{ item.sameDay ? '今天' : item.time }}</view>
  29. </view>
  30. </view>
  31. <view class="date-btn" v-if="sameDayData.isSign == 1">今日已签到</view><!-- @click="jumpUrl('/integralshop/share/index?categoryId=' + taskSign.bindId)" -->
  32. <view class="date-btn" v-else @click="signIn()">签到赚 {{ sameDayData.integral }} 积分</view>
  33. <!-- <view class="date-btn" v-else @click="jumpUrl('/integralshop/share/index?categoryId=' + taskSign.bindId)">签到赚 {{ sameDayData.integral }} 积分</view> -->
  34. </view>
  35. <view class="task">
  36. <view class="tits">积分任务</view>
  37. <view class="task-list" v-if="taskPageList && taskPageList.length > 0">
  38. <view class="li ddflex" v-for="(item, index) in taskPageList" :key="index">
  39. <view class="fflex">
  40. <view class="task-name">
  41. {{ item.title }}
  42. <text>+{{ item.reward }}</text>
  43. </view>
  44. <view class="task-bri">{{ item.brief }}</view>
  45. </view>
  46. <view class="li-r">
  47. <!-- isGet 0、未领取 1、已领取 -->
  48. <block v-if="item.isGet == 1">
  49. <view class="task-btn end" v-if="item.isCompletion == 1">已完成</view>
  50. <block v-else>
  51. <view
  52. v-if="item.bindType == 1 && item.completionCount != item.taskCount"
  53. class="task-btn ing"
  54. @click="jumpUrl('/integralshop/activity/index?bindId=' + item.bindId)"
  55. >
  56. 去完成
  57. </view>
  58. <view v-else class="task-btn ing" @click="getTaskReceiveReward(item.id, index)">领取积分</view>
  59. </block>
  60. </block>
  61. <view class="task-btn" v-else @click="getTaskReceive(item.id, index)">领取任务</view>
  62. <view class="task-num" v-if="item.taskCount > 0">{{ item.completionCount }}/{{ item.taskCount }}</view>
  63. <view class="task-num" v-else>不限次数</view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="nodata" v-else>
  68. <image :src="picUrlss + 'empty_dd.png'"></image>
  69. <text>暂无任务</text>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. // pages/sort/sort.js
  76. //获取应用实例
  77. const app = getApp();
  78. const req = require('../../utils/request.js');
  79. export default {
  80. data() {
  81. return {
  82. picUrlss: req.public.picUrls,
  83. systems: {},
  84. isTop: 0,
  85. taskPageList: '',
  86. integralData: '',
  87. taskSign: '',
  88. sameDayData: '' //当天
  89. };
  90. },
  91. onLoad: async function(options) {},
  92. onShow() {
  93. this.getTaskSign();
  94. this.getTaskPage();
  95. this.getIntegral();
  96. },
  97. onReachBottom() {},
  98. methods: {
  99. jumpUrl(url) {
  100. uni.navigateTo({
  101. url: url
  102. });
  103. },
  104. jumpUrlTab(url) {
  105. uni.switchTab({
  106. url: url
  107. });
  108. },
  109. getIntegral() {
  110. req.getRequest('/api/integral/totalIntegral', {}, res => {
  111. // console.log(res);
  112. this.integralData = res;
  113. });
  114. },
  115. getTaskSign() {
  116. req.getRequest('/api/v3/task/sign', { taskCode: 'top_sign' }, data => {
  117. this.taskSign = data;
  118. if (data && data.response && data.response.length > 0) {
  119. var list = data.response.filter(it => it.sameDay);
  120. if (list.length > 0) {
  121. this.sameDayData = list[0];
  122. }
  123. }
  124. });
  125. },
  126. getTaskPage() {
  127. req.getRequest('/api/v3/task/page', { limit: 20, page: 1 }, data => {
  128. this.taskPageList = data.list;
  129. });
  130. },
  131. getTaskReceive(taskId, index) {
  132. req.postRequest(
  133. '/api/v3/task/receive',
  134. { taskId: taskId },
  135. data => {
  136. this.getTaskPage();
  137. },
  138. true
  139. );
  140. },
  141. getTaskReceiveReward(taskId, index) {
  142. req.postRequest(
  143. '/api/v3/task/receive/reward',
  144. { taskId: taskId },
  145. data => {
  146. this.getTaskPage();
  147. this.getIntegral();
  148. },
  149. true
  150. );
  151. },
  152. signIn(id){
  153. req.postRequest('/api/integral/sign', {}, data => {
  154. if (data) {
  155. // req.msg('连续签到' + data.continuityDay + '天' + ',获得' + data.IntegralChange + '积分');
  156. this.sameDayData.isSign == 1
  157. this.getTaskSign();
  158. this.getIntegral();
  159. }
  160. });
  161. }
  162. },
  163. created() {
  164. const systemInfo = uni.getSystemInfoSync();
  165. // px转换到rpx的比例
  166. let pxToRpxScale = 750 / systemInfo.windowWidth;
  167. let systems = {
  168. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  169. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  170. };
  171. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  172. this.systems = systems;
  173. },
  174. onPageScroll: function(e) {
  175. if (e.scrollTop > this.systems.barHeight) {
  176. this.isTop = 1;
  177. } else {
  178. this.isTop = 0;
  179. }
  180. }
  181. };
  182. </script>
  183. <style>
  184. @import './index.css';
  185. </style>