index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view>
  3. <view v-if="(data_base || null) != null">
  4. <view class="padding-horizontal-main padding-top-main">
  5. <!-- 顶部 -->
  6. <view class="points-user tc pr border-radius-main spacing-mb">
  7. <navigator class="points-user-menu-submit round pa" url="/pages/user-integral/user-integral" hover-class="none">我的积分</navigator>
  8. <block v-if="(user || null) == null">
  9. <button class="login-submit round bg-white" type="default" size="mini" @tap="login_event">立即登录</button>
  10. <view class="desc margin-top-xxl">获知会员积分详情</view>
  11. </block>
  12. <block v-else>
  13. <image class="avatar dis-block circle" @tap="preview_event" :src="user.avatar || avatar_default" mode="widthFix"></image>
  14. <view class="cr-white margin-top-sm">{{user.user_name_view}}</view>
  15. <view class="desc margin-top-lg">当前可用 {{user_integral.integral || 0}} 积分</view>
  16. </block>
  17. <!-- 分享 -->
  18. <button class="share-submit round pa" type="default" size="mini" open-type="share">分享</button>
  19. </view>
  20. <!-- 广告图片 -->
  21. <view v-if="(data_base.right_images || null) != null" class="spacing-mb">
  22. <image class="wh-auto dis-block border-radius-main" :src="data_base.right_images" mode="widthFix" :data-value="data_base.right_images_url || ''" @tap="url_event"></image>
  23. </view>
  24. <!-- 公告信息 -->
  25. <view v-if="(data_base.points_desc || null) != null && data_base.points_desc.length > 0" class="spacing-mb">
  26. <view class="notice-content">
  27. <view v-for="(item, index) in data_base.points_desc" :key="index" class="item">{{item}}</view>
  28. </view>
  29. </view>
  30. <!-- 商品兑换 -->
  31. <view v-if="(data_base.goods_exchange_data || null) != null && data_base.goods_exchange_data.length > 0">
  32. <view class="spacing-nav-title">
  33. <text class="text-wrapper">商品兑换</text>
  34. <navigator url="/pages/goods-search/goods-search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
  35. </view>
  36. <view class="data-list oh">
  37. <view v-for="(item, index) in data_base.goods_exchange_data" :key="index" class="item padding-bottom-sm border-radius-main bg-white margin-bottom-main">
  38. <navigator :url="item.goods.goods_url" hover-class="none">
  39. <image class="goods-img dis-block" :src="item.goods.images" mode="aspectFit"></image>
  40. <view class="padding-horizontal-main margin-top-sm">
  41. <view class="multi-text">{{item.goods.title}}</view>
  42. <view class="single-text original-price margin-top-sm">{{currency_symbol}}{{item.goods.price}}</view>
  43. <view class="single-text">
  44. <text class="sales-price text-size">{{item.integral}}</text>
  45. <text class="cr-grey margin-left-xs">积分</text>
  46. </view>
  47. </view>
  48. </navigator>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 结尾 -->
  54. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  55. </view>
  56. <view v-else>
  57. <!-- 提示信息 -->
  58. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. const app = getApp();
  64. import componentNoData from "../../../../components/no-data/no-data";
  65. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  66. export default {
  67. data() {
  68. return {
  69. data_bottom_line_status: false,
  70. data_list_loding_status: 1,
  71. data_list_loding_msg: '',
  72. currency_symbol: app.globalData.data.currency_symbol,
  73. params: null,
  74. user: null,
  75. data_base: null,
  76. user_integral: null,
  77. avatar_default: app.globalData.data.default_user_head_src,
  78. // 自定义分享信息
  79. share_info: {}
  80. };
  81. },
  82. components: {
  83. componentNoData,
  84. componentBottomLine
  85. },
  86. props: {},
  87. onLoad(params) {
  88. this.setData({
  89. params: params,
  90. user: app.globalData.get_user_cache_info()
  91. });
  92. },
  93. onShow() {
  94. // 初始化配置
  95. this.init_config();
  96. // 获取数据
  97. this.get_data();
  98. },
  99. // 下拉刷新
  100. onPullDownRefresh() {
  101. this.get_data();
  102. },
  103. methods: {
  104. // 初始化配置
  105. init_config(status) {
  106. if ((status || false) == true) {
  107. this.setData({
  108. currency_symbol: app.globalData.get_config('currency_symbol'),
  109. });
  110. } else {
  111. app.globalData.is_config(this, 'init_config');
  112. }
  113. },
  114. // 获取数据
  115. get_data() {
  116. uni.request({
  117. url: app.globalData.get_request_url("index", "index", "points"),
  118. method: 'POST',
  119. data: {},
  120. dataType: 'json',
  121. success: res => {
  122. uni.stopPullDownRefresh();
  123. if (res.data.code == 0) {
  124. var data = res.data.data;
  125. this.setData({
  126. data_base: data.base || null,
  127. user_integral: data.user_integral || null,
  128. data_list_loding_msg: '',
  129. data_list_loding_status: 0,
  130. data_bottom_line_status: true
  131. });
  132. if ((this.data_base || null) != null) {
  133. // 基础自定义分享
  134. this.setData({
  135. share_info: {
  136. title: this.data_base.seo_title || this.data_base.application_name,
  137. desc: this.data_base.seo_desc,
  138. path: '/pages/plugins/points/index/index',
  139. img: this.data_base.right_images
  140. }
  141. });
  142. // 导航名称
  143. if((this.data_base.application_name || null) != null) {
  144. uni.setNavigationBarTitle({
  145. title: this.data_base.application_name
  146. });
  147. }
  148. }
  149. } else {
  150. this.setData({
  151. data_bottom_line_status: false,
  152. data_list_loding_status: 2,
  153. data_list_loding_msg: res.data.msg
  154. });
  155. }
  156. // 分享菜单处理
  157. app.globalData.page_share_handle(this.share_info);
  158. },
  159. fail: () => {
  160. uni.stopPullDownRefresh();
  161. this.setData({
  162. data_bottom_line_status: false,
  163. data_list_loding_status: 2,
  164. data_list_loding_msg: '服务器请求出错'
  165. });
  166. app.globalData.showToast('服务器请求出错');
  167. }
  168. });
  169. },
  170. // 立即登录
  171. login_event() {
  172. var user = app.globalData.get_user_info(this, "login_event");
  173. if (user != false) {
  174. // 用户未绑定用户则转到登录页面
  175. if (app.globalData.user_is_need_login(user)) {
  176. uni.showModal({
  177. title: '温馨提示',
  178. content: '绑定手机号码',
  179. confirmText: '确认',
  180. cancelText: '暂不',
  181. success: result => {
  182. uni.stopPullDownRefresh();
  183. if (result.confirm) {
  184. uni.navigateTo({
  185. url: "/pages/login/login?event_callback=init"
  186. });
  187. }
  188. }
  189. });
  190. }
  191. }
  192. this.setData({
  193. user: user || null
  194. });
  195. },
  196. // url事件
  197. url_event(e) {
  198. app.globalData.url_event(e);
  199. },
  200. // 头像查看
  201. preview_event() {
  202. if (app.globalData.data.default_user_head_src != this.user.avatar) {
  203. uni.previewImage({
  204. current: this.user.avatar,
  205. urls: [this.user.avatar]
  206. });
  207. }
  208. }
  209. }
  210. };
  211. </script>
  212. <style>
  213. @import './index.css';
  214. </style>