index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view>
  3. <view v-if="(data_base || null) != null">
  4. <!-- 列表 -->
  5. <scroll-view :scroll-y="true" class="scroll-box scroll-box-ece-nav plugins-binding-data-list" @scrolltolower="scroll_lower" lower-threshold="60">
  6. <view v-if="(data_list || null) != null && data_list.length > 0" class="data-list padding-horizontal-main padding-top-main oh">
  7. <block v-for="(item, index) in data_list" :key="index">
  8. <view class="item border-radius-main bg-white padding-main oh spacing-mb">
  9. <navigator :url="'/pages/plugins/binding/detail/detail?id=' + item.id" hover-class="none">
  10. <image :src="item.images" mode="aspectFit" class="images fl dis-block border-radius-main"></image>
  11. <view class="base-right fr bs-bb">
  12. <view class="fw-b text-size cr-base single-text">{{item.title}}</view>
  13. <view class="cr-grey margin-top-xs text-size-xs multi-text">{{item.describe}}</view>
  14. <view class="sales-price margin-top-sm single-text">{{currency_symbol}}{{item.estimate_price}}</view>
  15. <view v-if="item.estimate_original_price != 0" class="original-price margin-top-xs single-text">{{currency_symbol}}{{item.estimate_original_price}}</view>
  16. <view v-if="(item.estimate_discount_price || 0) != 0" class="margin-top-sm single-text">
  17. <text class="discount-icon cr-white text-size-xs">节省</text>
  18. <text class="cr-green">{{currency_symbol}}{{item.estimate_discount_price}}</text>
  19. </view>
  20. </view>
  21. </navigator>
  22. </view>
  23. </block>
  24. </view>
  25. <view v-else>
  26. <!-- 提示信息 -->
  27. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  28. </view>
  29. <!-- 结尾 -->
  30. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  31. <!-- 回到店铺 -->
  32. <view v-if="(shop || null) != null && shop.length > 0" class="bottom-fixed padding-main">
  33. <button class="bg-main br-main cr-white round dis-block" type="default" hover-class="none" size="mini" @tap="shop_event" :data-value="shop.url">
  34. <view class="dis-inline-block va-m">
  35. <uni-icons type="shop" size="16" color="#fff"></uni-icons>
  36. </view>
  37. <text class="va-m margin-left-sm">回到店铺</text>
  38. </button>
  39. </view>
  40. </scroll-view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. const app = getApp();
  46. import componentNoData from "../../../../components/no-data/no-data";
  47. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  48. export default {
  49. data() {
  50. return {
  51. data_list_loding_status: 1,
  52. data_list_loding_msg: '',
  53. data_bottom_line_status: false,
  54. currency_symbol: app.globalData.data.currency_symbol,
  55. data_list: [],
  56. data_total: 0,
  57. data_page_total: 0,
  58. data_page: 1,
  59. params: null,
  60. data_base: null,
  61. shop: null,
  62. // 自定义分享信息
  63. share_info: {}
  64. };
  65. },
  66. components: {
  67. componentNoData,
  68. componentBottomLine
  69. },
  70. onLoad(params) {
  71. this.setData({
  72. params: params
  73. });
  74. // 初始化配置
  75. this.init_config();
  76. // 获取数据
  77. this.get_data();
  78. },
  79. // 下拉刷新
  80. onPullDownRefresh() {
  81. this.setData({
  82. data_page: 1
  83. });
  84. this.get_data_list(1);
  85. },
  86. methods: {
  87. // 初始化配置
  88. init_config(status) {
  89. if ((status || false) == true) {
  90. this.setData({
  91. currency_symbol: app.globalData.get_config('currency_symbol'),
  92. });
  93. } else {
  94. app.globalData.is_config(this, 'init_config');
  95. }
  96. },
  97. // 初始化
  98. get_data() {
  99. uni.request({
  100. url: app.globalData.get_request_url("index", "index", "binding"),
  101. method: 'POST',
  102. data: this.params,
  103. dataType: 'json',
  104. success: res => {
  105. uni.stopPullDownRefresh();
  106. if (res.data.code == 0) {
  107. var data = res.data.data;
  108. this.setData({
  109. data_base: data.base || null,
  110. shop: data.shop || null
  111. });
  112. if ((this.data_base || null) != null) {
  113. // 基础自定义分享
  114. this.setData({
  115. share_info: {
  116. title: this.data_base.seo_title || this.data_base.application_name,
  117. desc: this.data_base.seo_desc,
  118. path: '/pages/plugins/binding/index/index'
  119. }
  120. });
  121. // 导航名称
  122. if((this.data_base.application_name || null) != null) {
  123. uni.setNavigationBarTitle({
  124. title: this.data_base.application_name
  125. });
  126. }
  127. }
  128. // 获取列表数据
  129. this.get_data_list(1);
  130. } else {
  131. this.setData({
  132. data_list_loding_status: 0,
  133. data_list_loding_msg: res.data.msg
  134. });
  135. app.globalData.showToast(res.data.msg);
  136. }
  137. // 分享菜单处理
  138. app.globalData.page_share_handle(this.share_info);
  139. },
  140. fail: () => {
  141. uni.stopPullDownRefresh();
  142. this.setData({
  143. data_list_loding_status: 2
  144. });
  145. app.globalData.showToast('服务器请求出错');
  146. }
  147. });
  148. },
  149. // 获取数据列表
  150. get_data_list(is_mandatory) {
  151. // 分页是否还有数据
  152. if ((is_mandatory || 0) == 0) {
  153. if (this.data_bottom_line_status == true) {
  154. uni.stopPullDownRefresh();
  155. return false;
  156. }
  157. }
  158. // 加载loding
  159. uni.showLoading({
  160. title: '加载中...'
  161. });
  162. // 获取数据
  163. uni.request({
  164. url: app.globalData.get_request_url("datalist", "index", "binding"),
  165. method: 'POST',
  166. data: {
  167. page: this.data_page,
  168. shop_id: this.params.spid || 0
  169. },
  170. dataType: 'json',
  171. success: res => {
  172. uni.hideLoading();
  173. uni.stopPullDownRefresh();
  174. if (res.data.code == 0) {
  175. var data = res.data.data;
  176. if (data.data.length > 0) {
  177. if (this.data_page <= 1) {
  178. var temp_data_list = data.data;
  179. } else {
  180. var temp_data_list = this.data_list || [];
  181. var temp_data = data.data;
  182. for (var i in temp_data) {
  183. temp_data_list.push(temp_data[i]);
  184. }
  185. }
  186. this.setData({
  187. data_list: temp_data_list,
  188. data_total: data.total,
  189. data_page_total: data.page_total,
  190. data_list_loding_status: 3,
  191. data_page: this.data_page + 1
  192. });
  193. // 是否还有数据
  194. this.setData({
  195. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  196. });
  197. } else {
  198. this.setData({
  199. data_list_loding_status: 0
  200. });
  201. if (this.data_page <= 1) {
  202. this.setData({
  203. data_list: [],
  204. data_bottom_line_status: false
  205. });
  206. }
  207. }
  208. } else {
  209. this.setData({
  210. data_list_loding_status: 0,
  211. data_list_loding_msg: res.data.msg
  212. });
  213. app.globalData.showToast(res.data.msg);
  214. }
  215. },
  216. fail: () => {
  217. uni.hideLoading();
  218. uni.stopPullDownRefresh();
  219. this.setData({
  220. data_list_loding_status: 2
  221. });
  222. app.globalData.showToast('服务器请求出错');
  223. }
  224. });
  225. },
  226. // 滚动加载
  227. scroll_lower(e) {
  228. this.get_data_list();
  229. },
  230. // 店铺事件
  231. shop_event(e) {
  232. var prev_url = app.globalData.prev_page();
  233. if(prev_url != null && prev_url.indexOf('pages/plugins/shop/detail/detail') != -1) {
  234. uni.navigateBack();
  235. } else {
  236. app.globalData.url_event(e);
  237. }
  238. }
  239. }
  240. };
  241. </script>
  242. <style>
  243. @import './index.css';
  244. </style>