frequencycard-list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <!-- 导航 -->
  4. <view class="nav-base bg-white">
  5. <block v-for="(item, index) in nav_status_list" :key="index">
  6. <view v-if="nav_status_index == index" class="item fl tc cr-main" :data-index="index" @tap="nav_event">{{item.name}}</view>
  7. <view v-else class="item fl tc" :data-index="index" @tap="nav_event">{{item.name}}</view>
  8. </block>
  9. </view>
  10. <!-- 数据列表 -->
  11. <scroll-view :scroll-y="true" class="scroll-box scroll-box-ece-nav" @scrolltolower="scroll_lower" lower-threshold="60">
  12. <view v-if="data_list.length > 0" class="padding-horizontal-main padding-top-main">
  13. <view v-for="(item, index) in data_list" :key="index" class="list-item padding-horizontal-main padding-top-main border-radius-main bg-white oh spacing-mb">
  14. <view class="item-base oh br-b padding-bottom-main">
  15. <text class="fl cr-base">{{item.add_time}}</text>
  16. <text class="fr cr-red">{{item.status_name}}<text v-if="(item.is_under_line_text || null) != null">({{item.is_under_line_text}})</text></text>
  17. </view>
  18. <view class="br-b padding-vertical-main">
  19. <view class="cr-base">{{item.name}}</view>
  20. <view v-if="(item.describe || null) != null" class="cr-grey margin-top-xs">{{item.describe}}</view>
  21. </view>
  22. <view class="padding-vertical-main">
  23. <block v-for="(fv,fi) in content_list">
  24. <view class="single-text margin-top-xs">
  25. <text class="cr-gray margin-right-xl">{{fv.name}}</text>
  26. <text class="cr-base">{{item[fv.field]}}</text>
  27. <text v-if="(fv.unit || null) != null" class="cr-gray">{{fv.unit}}</text>
  28. </view>
  29. </block>
  30. </view>
  31. <view class="item-operation tr br-t padding-vertical-main">
  32. <button class="round bg-white cr-green br-green" type="default" size="mini" @tap="url_event" :data-value="'/pages/plugins/realstore/frequencycard-used/frequencycard-used?cuid='+item.id" hover-class="none">使用记录</button>
  33. </view>
  34. </view>
  35. </view>
  36. <view v-else>
  37. <!-- 提示信息 -->
  38. <component-no-data :propStatus="data_list_loding_status"></component-no-data>
  39. </view>
  40. <!-- 结尾 -->
  41. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  42. </scroll-view>
  43. </view>
  44. </template>
  45. <script>
  46. const app = getApp();
  47. import componentNoData from "../../../../components/no-data/no-data";
  48. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  49. export default {
  50. data() {
  51. return {
  52. data_list: [],
  53. data_total: 0,
  54. data_page_total: 0,
  55. data_page: 1,
  56. data_list_loding_status: 1,
  57. data_bottom_line_status: false,
  58. params: null,
  59. nav_status_list: [
  60. { name: "全部", value: "-1" },
  61. { name: "有效", value: "0" },
  62. { name: "暂停", value: "1" },
  63. { name: "结束", value: "2" },
  64. { name: "关闭", value: "3" },
  65. ],
  66. nav_status_index: 0,
  67. content_list: [
  68. {name: "可用次数", field: "valid_number", unit: "次"},
  69. {name: "已用次数", field: "use_number", unit: "次"},
  70. {name: "起始时间", field: "start_time"},
  71. {name: "结束时间", field: "end_time"}
  72. ]
  73. };
  74. },
  75. components: {
  76. componentNoData,
  77. componentBottomLine
  78. },
  79. props: {},
  80. onLoad(params) {
  81. // 是否指定状态
  82. var nav_status_index = 0;
  83. if ((params.status || null) != null) {
  84. for (var i in this.nav_status_list) {
  85. if (this.nav_status_list[i]['value'] == params.status) {
  86. nav_status_index = i;
  87. break;
  88. }
  89. }
  90. }
  91. this.setData({
  92. params: params,
  93. nav_status_index: nav_status_index
  94. });
  95. // 数据加载
  96. this.init();
  97. },
  98. onShow() {
  99. // 分享菜单处理
  100. app.globalData.page_share_handle();
  101. },
  102. // 下拉刷新
  103. onPullDownRefresh() {
  104. this.setData({
  105. data_page: 1
  106. });
  107. this.get_data_list(1);
  108. },
  109. methods: {
  110. // 获取数据
  111. init() {
  112. var user = app.globalData.get_user_info(this, 'init');
  113. if (user != false) {
  114. // 用户未绑定用户则转到登录页面
  115. if (app.globalData.user_is_need_login(user)) {
  116. uni.redirectTo({
  117. url: "/pages/login/login?event_callback=init"
  118. });
  119. return false;
  120. } else {
  121. // 获取数据
  122. this.get_data_list();
  123. }
  124. } else {
  125. this.setData({
  126. data_list_loding_status: 0,
  127. data_bottom_line_status: false
  128. });
  129. }
  130. },
  131. // 获取数据
  132. get_data_list(is_mandatory) {
  133. // 分页是否还有数据
  134. if ((is_mandatory || 0) == 0) {
  135. if (this.data_bottom_line_status == true) {
  136. uni.stopPullDownRefresh();
  137. return false;
  138. }
  139. }
  140. // 加载loding
  141. uni.showLoading({
  142. title: '加载中...'
  143. });
  144. this.setData({
  145. data_list_loding_status: 1
  146. });
  147. // 参数
  148. var status = (this.nav_status_list[this.nav_status_index] || null) == null ? -1 : this.nav_status_list[this.nav_status_index]['value'];
  149. // 获取数据
  150. uni.request({
  151. url: app.globalData.get_request_url("index", "frequencycard", "realstore"),
  152. method: 'POST',
  153. data: {
  154. page: this.data_page,
  155. status: status,
  156. oid: this.params.oid || 0
  157. },
  158. dataType: 'json',
  159. success: res => {
  160. uni.hideLoading();
  161. uni.stopPullDownRefresh();
  162. if (res.data.code == 0) {
  163. if (res.data.data.data.length > 0) {
  164. if (this.data_page <= 1) {
  165. var temp_data_list = res.data.data.data;
  166. } else {
  167. var temp_data_list = this.data_list || [];
  168. var temp_data = res.data.data.data;
  169. for (var i in temp_data) {
  170. temp_data_list.push(temp_data[i]);
  171. }
  172. }
  173. this.setData({
  174. data_list: temp_data_list,
  175. data_total: res.data.data.total,
  176. data_page_total: res.data.data.page_total,
  177. data_list_loding_status: 3,
  178. data_page: this.data_page + 1
  179. });
  180. // 是否还有数据
  181. this.setData({
  182. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  183. });
  184. } else {
  185. this.setData({
  186. data_list_loding_status: 0,
  187. data_list: [],
  188. data_bottom_line_status: false
  189. });
  190. }
  191. } else {
  192. this.setData({
  193. data_list_loding_status: 0
  194. });
  195. if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
  196. app.globalData.showToast(res.data.msg);
  197. }
  198. }
  199. },
  200. fail: () => {
  201. uni.hideLoading();
  202. uni.stopPullDownRefresh();
  203. this.setData({
  204. data_list_loding_status: 2,
  205. load_status: 1
  206. });
  207. app.globalData.showToast('服务器请求出错');
  208. }
  209. });
  210. },
  211. // 滚动加载
  212. scroll_lower(e) {
  213. this.get_data_list();
  214. },
  215. // 导航事件
  216. nav_event(e) {
  217. this.setData({
  218. nav_status_index: e.currentTarget.dataset.index || 0,
  219. data_page: 1
  220. });
  221. // 重新拉取数据
  222. this.get_data_list(1);
  223. },
  224. // url事件
  225. url_event(e) {
  226. app.globalData.url_event(e);
  227. }
  228. }
  229. };
  230. </script>
  231. <style>
  232. @import './frequencycard-list.css';
  233. </style>