user.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view>
  3. <view v-if="(data_base || null) != null">
  4. <view class="padding-horizontal-main padding-top-main oh">
  5. <!-- 头部 -->
  6. <view class="head-box padding-main border-radius-main oh pr spacing-mb">
  7. <view class="head-item tc fl">
  8. <view class="avatar bg-white circle">
  9. <image class="dis-block circle" @tap="preview_event" @error="user_avatar_error" :src="avatar" mode="widthFix"></image>
  10. </view>
  11. <text class="margin-top-sm dis-block cr-white">{{nickname}}</text>
  12. </view>
  13. <view class="head-base fr">
  14. <view v-if="(user_level || null) != null" class="single-text tr">
  15. <image v-if="(user_level.images_url || null) != null" class="level-icon va-m margin-right-sm" :src="user_level.images_url" mode="widthFix"></image>
  16. <text v-if="(user_level.name || null) != null" class="level-name text-size-sm fw-b va-m">{{user_level.name}}</text>
  17. </view>
  18. <block v-if="(data_base || null) != null && (data_base.is_enable_self_extraction || 0) == 1">
  19. <navigator url="/pages/plugins/distribution/extraction/extraction" hover-class="none">
  20. <button class="head-base-submit pa bg-white cr-main round text-size-sm" size="mini" type="default" hover-class="none">{{(extraction || null) == null ? '申请' : ''}}取货点</button>
  21. </navigator>
  22. </block>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 上级用户 -->
  27. <view v-if="(superior || null) != null" class="superior bg-white border-radius-main margin-horizontal-main margin-bottom-main oh">
  28. <view class="superior-title cr-white fw-b va-m fl">上级用户</view>
  29. <view class="superior-content fl padding-main single-text">
  30. <image :src="superior.avatar" mode="aspectFit" class="circle va-m"></image>
  31. <text class="cr-gray va-m margin-left-sm">{{superior.user_name_view}}</text>
  32. </view>
  33. </view>
  34. <!-- 会员中心通知 -->
  35. <view v-if="(user_level || null) != null && (data_base.user_center_notice || null) != null && data_base.user_center_notice.length > 0" class="padding-horizontal-main padding-bottom-main">
  36. <view class="notice-content">
  37. <view v-for="(item, index) in data_base.user_center_notice" :key="index" class="item">{{item}}</view>
  38. </view>
  39. </view>
  40. <!-- 导航 -->
  41. <view v-if="nav_list.length > 0" class="nav oh">
  42. <block v-for="(item, index) in nav_list" :key="index">
  43. <view class="item fl tc padding-main border-radius-main bg-white">
  44. <navigator :url="item.url" hover-class="none">
  45. <image :src="item.icon" mode="scaleToFill" class="dis-block"></image>
  46. <view class="tc cr-base margin-top-lg">{{item.title}}</view>
  47. </navigator>
  48. </view>
  49. </block>
  50. </view>
  51. <!-- 不符合分销条件描述 -->
  52. <view v-if="(user_level || null) == null && (data_base.non_conformity_desc || null) != null && data_base.non_conformity_desc.length > 0" class="padding-horizontal-main padding-bottom-main">
  53. <view class="notice-content-blue">
  54. <view v-for="(item, index) in data_base.non_conformity_desc" :key="index" class="item">{{item}}</view>
  55. </view>
  56. </view>
  57. <!-- 阶梯返佣提示 -->
  58. <view v-if="(profit_ladder || null) != null" class="padding-horizontal-main padding-bottom-main">
  59. <text class="cr-blue">{{profit_ladder.msg}}</text>
  60. <navigator url="/pages/plugins/distribution/poster/poster" hover-class="none" class="bg-green cr-white dis-inline-block round padding-top-xs padding-bottom-xs padding-horizontal-main">去推广</navigator>
  61. </view>
  62. </view>
  63. <view v-else>
  64. <!-- 提示信息 -->
  65. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. const app = getApp();
  71. import componentNoData from "../../../../components/no-data/no-data";
  72. export default {
  73. data() {
  74. return {
  75. data_bottom_line_status: false,
  76. data_list_loding_status: 1,
  77. data_list_loding_msg: '',
  78. data_base: null,
  79. user_level: null,
  80. extraction: null,
  81. superior: null,
  82. profit_ladder: null,
  83. nav_list: [],
  84. avatar: app.globalData.data.default_user_head_src,
  85. nickname: "用户名"
  86. };
  87. },
  88. components: {
  89. componentNoData
  90. },
  91. props: {},
  92. onLoad(params) {},
  93. onShow() {
  94. this.init();
  95. // 分享菜单处理
  96. app.globalData.page_share_handle();
  97. },
  98. // 下拉刷新
  99. onPullDownRefresh() {
  100. this.get_data();
  101. },
  102. methods: {
  103. init(e) {
  104. var user = app.globalData.get_user_info(this, "init");
  105. if (user != false) {
  106. // 用户未绑定用户则转到登录页面
  107. if (app.globalData.user_is_need_login(user)) {
  108. uni.showModal({
  109. title: '温馨提示',
  110. content: '绑定手机号码',
  111. confirmText: '确认',
  112. cancelText: '暂不',
  113. success: result => {
  114. uni.stopPullDownRefresh();
  115. if (result.confirm) {
  116. uni.navigateTo({
  117. url: "/pages/login/login?event_callback=init"
  118. });
  119. }
  120. this.set_user_base(user);
  121. }
  122. });
  123. } else {
  124. this.set_user_base(user);
  125. this.get_data();
  126. }
  127. }
  128. },
  129. // 设置用户基础信息
  130. set_user_base(user) {
  131. if((user.avatar || null) != null) {
  132. this.setData({"avatar": user.avatar});
  133. }
  134. if((user.user_name_view || null) != null) {
  135. this.setData({"nickname": user.user_name_view});
  136. }
  137. },
  138. // 获取数据
  139. get_data() {
  140. uni.request({
  141. url: app.globalData.get_request_url("index", "user", "distribution"),
  142. method: 'POST',
  143. data: {},
  144. dataType: 'json',
  145. success: res => {
  146. uni.stopPullDownRefresh();
  147. if (res.data.code == 0) {
  148. var data = res.data.data;
  149. this.setData({
  150. data_base: data.base || null,
  151. user_level: data.user_level || null,
  152. extraction: data.extraction || null,
  153. superior: data.superior || null,
  154. profit_ladder: data.profit_ladder || null,
  155. nav_list: data.nav_list || [],
  156. data_list_loding_msg: '',
  157. data_list_loding_status: 0,
  158. data_bottom_line_status: false
  159. });
  160. } else {
  161. this.setData({
  162. data_bottom_line_status: false,
  163. data_list_loding_status: 2,
  164. data_list_loding_msg: res.data.msg
  165. });
  166. if (app.globalData.is_login_check(res.data, this, 'get_data')) {
  167. app.globalData.showToast(res.data.msg);
  168. }
  169. }
  170. },
  171. fail: () => {
  172. uni.stopPullDownRefresh();
  173. this.setData({
  174. data_bottom_line_status: false,
  175. data_list_loding_status: 2,
  176. data_list_loding_msg: '服务器请求出错'
  177. });
  178. app.globalData.showToast('服务器请求出错');
  179. }
  180. });
  181. },
  182. // 头像查看
  183. preview_event() {
  184. if (app.globalData.data.default_user_head_src != this.avatar) {
  185. uni.previewImage({
  186. current: this.avatar,
  187. urls: [this.avatar]
  188. });
  189. }
  190. },
  191. // 头像加载错误
  192. user_avatar_error(e) {
  193. this.setData({
  194. avatar: app.globalData.data.default_user_head_src
  195. });
  196. }
  197. }
  198. };
  199. </script>
  200. <style>
  201. @import './user.css';
  202. </style>