member-code.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="scroll-box bg-white">
  3. <!-- 主体内容 -->
  4. <block v-if="data_list_loding_status == 3">
  5. <!-- 条码 -->
  6. <view class="brcode auto">
  7. <w-barcode :options="barcode"></w-barcode>
  8. <view class="fw-b tc margin-top text-size-lg">{{member_code}}</view>
  9. </view>
  10. <!-- 二维码 -->
  11. <view class="qrcode auto br radius">
  12. <w-qrcode :options="qrcode"></w-qrcode>
  13. </view>
  14. <!-- 提示信息 -->
  15. <view class="cr-grey tc margin-top-xxxl">如遇到扫码失败请将屏幕调至最亮重新扫码</view>
  16. <!-- 导航 -->
  17. <view v-if="(plugins_wallet || null) != null" class="bottom-fixed padding-main">
  18. <view class="bottom-line-exclude oh">
  19. <view class="bg-gray round oh">
  20. <button type="default" class="bg-main br-main cr-white round text-size fl" size="mini">会员码</button>
  21. <button type="default" class="bg-gray br-gray cr-base round text-size fr" size="mini" :data-value="'/pages/plugins/wallet/payment-code/payment-code?screen_brightness_value='+screen_brightness_value" data-redirect="1" @tap="url_event">钱包付款码</button>
  22. </view>
  23. </view>
  24. </view>
  25. </block>
  26. <!-- 错误提示 -->
  27. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  28. <view v-if="is_to_login == 1" class="margin-top-lg tc">
  29. <button type="default" class="bg-main br-main cr-white" size="mini" data-value="/pages/login/login" @tap="url_event">去登录</button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. const app = getApp();
  35. import componentNoData from "../../../../components/no-data/no-data";
  36. export default {
  37. data() {
  38. return {
  39. data_list_loding_status: 1,
  40. data_list_loding_msg: '',
  41. is_to_login: 0,
  42. screen_brightness_value: 0,
  43. plugins_wallet: null,
  44. user: null,
  45. member_code: '',
  46. barcode:{
  47. width: 660,
  48. height: 120,
  49. code: ''
  50. },
  51. qrcode:{
  52. code: '',
  53. size: 450,
  54. }
  55. }
  56. },
  57. components: {
  58. componentNoData
  59. },
  60. // 页面加载初始化
  61. onLoad(params) {
  62. // 获取屏幕亮度
  63. // #ifndef H5
  64. var self = this;
  65. if((params || null) != null && (params.screen_brightness_value || null) == null) {
  66. uni.getScreenBrightness({
  67. success: function (res) {
  68. self.setData({
  69. screen_brightness_value: res.value
  70. });
  71. }
  72. });
  73. } else {
  74. self.setData({
  75. screen_brightness_value: params.screen_brightness_value
  76. });
  77. }
  78. // #endif
  79. },
  80. onShow() {
  81. // 数据加载
  82. this.init();
  83. // 初始化配置
  84. this.init_config();
  85. },
  86. methods: {
  87. // 初始化配置
  88. init_config(status) {
  89. if ((status || false) == true) {
  90. this.setData({
  91. plugins_wallet: app.globalData.get_config('plugins_base.wallet', null)
  92. });
  93. } else {
  94. app.globalData.is_config(this, 'init_config');
  95. }
  96. },
  97. // 获取数据
  98. init() {
  99. var user = app.globalData.get_user_info(this, 'init');
  100. if (user != false) {
  101. // 用户未绑定用户则转到登录页面
  102. if (app.globalData.user_is_need_login(user)) {
  103. uni.redirectTo({
  104. url: "/pages/login/login?event_callback=init"
  105. });
  106. this.setData({
  107. data_list_loding_status: 0,
  108. data_list_loding_msg: '请先绑定手机',
  109. is_to_login: 1
  110. });
  111. return false;
  112. } else {
  113. if((user.number_code || null) != null) {
  114. // 会员码数据
  115. var barcode = this.barcode;
  116. var qrcode = this.qrcode;
  117. barcode['code'] = user.number_code;
  118. qrcode['code'] = user.number_code;
  119. this.setData({
  120. data_list_loding_status: 3,
  121. is_to_login: 0,
  122. user: user,
  123. barcode: barcode,
  124. qrcode: qrcode,
  125. member_code: user.number_code,
  126. });
  127. // #ifndef H5
  128. // 设置屏幕亮度
  129. uni.setScreenBrightness({
  130. value: 1
  131. });
  132. // #endif
  133. } else {
  134. this.setData({
  135. data_list_loding_status: 0,
  136. data_list_loding_msg: '会员码为空',
  137. is_to_login: 0
  138. });
  139. }
  140. }
  141. } else {
  142. this.setData({
  143. data_list_loding_status: 0,
  144. data_list_loding_msg: '请先登录',
  145. is_to_login: 1
  146. });
  147. }
  148. },
  149. // url事件
  150. url_event(e) {
  151. app.globalData.url_event(e);
  152. }
  153. },
  154. // 页面销毁时执行
  155. onUnload: function() {
  156. // #ifndef H5
  157. // 恢复屏幕原始亮度
  158. if(this.screen_brightness_value > 0) {
  159. uni.setScreenBrightness({
  160. value: this.screen_brightness_value
  161. });
  162. }
  163. // #endif
  164. }
  165. }
  166. </script>
  167. <style>
  168. @import './member-code.css';
  169. </style>