user.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. <block v-if="(user_vip || null) != null">
  15. <block v-if="(user_vip.user_vip_model || null) == 'pay'">
  16. <view v-if="(user_vip || null) != null" class="single-text tr margin-bottom-sm">
  17. <image v-if="(user_vip.icon || null) != null" class="level-icon va-m margin-right-sm" :src="user_vip.icon" mode="widthFix"></image>
  18. <text v-if="(user_vip.name || null) != null" class="level-name text-size-sm fw-b va-m">{{user_vip.level_name}}</text>
  19. </view>
  20. <view class="tr">
  21. <block v-if="(user_vip.is_permanent || 0) == 1">
  22. <text class="cr-grey">有效期</text>
  23. <text class="cr-white fw-b margin-left-xs margin-right-xs">{{user_vip.permanent_value}}</text>
  24. <text class="cr-grey">{{user_vip.permanent_unit}}</text>
  25. </block>
  26. <block v-else>
  27. <block v-if="(user_vip.surplus_time_number || 0) == 0">
  28. <view class="cr-grey">会员已过期或未开通</view>
  29. <navigator url="/pages/plugins/membershiplevelvip/buy/buy" hover-class="none">
  30. <button v-if="(data_base.is_user_buy || null) == 1" class="submit-buy round pa" type="default" size="mini" hover-class="none">开通会员</button>
  31. </navigator>
  32. </block>
  33. <block v-else>
  34. <text class="cr-grey">有效期</text>
  35. <text class="cr-white fw-b margin-left-xs margin-right-xs">{{user_vip.surplus_time_number}}</text>
  36. <text class="cr-grey">{{user_vip.surplus_time_unit}}</text>
  37. <block v-if="(user_vip.is_supported_renew || null) == null || user_vip.is_supported_renew != 1">
  38. <block v-if="(data_base.is_supported_renew_old_order || null) == 1">
  39. <button size="mini" type="default" hover-class="none" class="renew-buy" @tap="uservip_renew_event" :disabled="submit_disabled_status">续费会员</button>
  40. </block>
  41. <block v-else>
  42. <block v-if="(data_base || null) != null && (data_base.is_user_buy || 0) == 1">
  43. <navigator url="/pages/plugins/membershiplevelvip/buy/buy" hover-class="none">
  44. <button class="submit-buy round pa" type="default" size="mini" hover-class="none">连续开通</button>
  45. </navigator>
  46. </block>
  47. </block>
  48. </block>
  49. </block>
  50. </block>
  51. </view>
  52. </block>
  53. <block v-else>
  54. <view v-if="(user_vip || null) != null" class="single-text tr">
  55. <image v-if="(user_vip.icon || null) != null" class="level-icon va-m margin-right-sm" :src="user_vip.icon" mode="widthFix"></image>
  56. <text v-if="(user_vip.name || null) != null" class="level-name text-size-sm fw-b va-m">{{user_vip.level_name}}</text>
  57. </view>
  58. </block>
  59. </block>
  60. <block v-else>
  61. <block v-if="(data_base || null) != null && (data_base.is_user_buy || 0) == 1">
  62. <navigator url="/pages/plugins/membershiplevelvip/buy/buy" hover-class="none">
  63. <button class="submit-buy round pa" type="default" size="mini" hover-class="none">开通会员</button>
  64. </navigator>
  65. </block>
  66. </block>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 会员中心通知 -->
  71. <view v-if="(user_vip || null) != null && (data_base.user_vip_center_notice || null) != null && data_base.user_vip_center_notice.length > 0" class="padding-horizontal-main padding-bottom-main">
  72. <view class="notice-content">
  73. <view v-for="(item, index) in data_base.user_vip_center_notice" :key="index" class="item">{{item}}</view>
  74. </view>
  75. </view>
  76. <!-- 导航 -->
  77. <view v-if="nav_list.length > 0" class="nav oh">
  78. <block v-for="(item, index) in nav_list" :key="index">
  79. <view class="item fl tc padding-main border-radius-main bg-white">
  80. <navigator :url="item.url" hover-class="none">
  81. <image :src="item.icon" mode="scaleToFill" class="dis-block"></image>
  82. <view class="tc cr-base margin-top-lg">{{item.title}}</view>
  83. </navigator>
  84. </view>
  85. </block>
  86. </view>
  87. <!-- 会员中心通知 -->
  88. <view v-if="(data_base.not_opening_vip_desc || null) != null && data_base.not_opening_vip_desc.length > 0" class="padding-horizontal-main padding-bottom-main">
  89. <view class="notice-content-blue">
  90. <view v-for="(item, index) in data_base.not_opening_vip_desc" :key="index" class="item">{{item}}</view>
  91. </view>
  92. </view>
  93. </view>
  94. <view v-else>
  95. <!-- 提示信息 -->
  96. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. const app = getApp();
  102. import componentNoData from "../../../../components/no-data/no-data";
  103. export default {
  104. data() {
  105. return {
  106. data_bottom_line_status: false,
  107. data_list_loding_status: 1,
  108. data_list_loding_msg: '',
  109. data_base: null,
  110. user_vip: null,
  111. nav_list: [],
  112. avatar: app.globalData.data.default_user_head_src,
  113. nickname: "用户名",
  114. submit_disabled_status: false
  115. };
  116. },
  117. components: {
  118. componentNoData
  119. },
  120. props: {},
  121. onLoad(params) {},
  122. onShow() {
  123. this.init();
  124. // 分享菜单处理
  125. app.globalData.page_share_handle();
  126. },
  127. // 下拉刷新
  128. onPullDownRefresh() {
  129. this.get_data();
  130. },
  131. methods: {
  132. init(e) {
  133. var user = app.globalData.get_user_info(this, "init");
  134. if (user != false) {
  135. // 用户未绑定用户则转到登录页面
  136. if (app.globalData.user_is_need_login(user)) {
  137. uni.showModal({
  138. title: '温馨提示',
  139. content: '绑定手机号码',
  140. confirmText: '确认',
  141. cancelText: '暂不',
  142. success: result => {
  143. uni.stopPullDownRefresh();
  144. if (result.confirm) {
  145. uni.navigateTo({
  146. url: "/pages/login/login?event_callback=init"
  147. });
  148. }
  149. this.set_user_base(user);
  150. }
  151. });
  152. } else {
  153. this.set_user_base(user);
  154. this.get_data();
  155. }
  156. }
  157. },
  158. // 设置用户基础信息
  159. set_user_base(user) {
  160. if((user.avatar || null) != null) {
  161. this.setData({"avatar": user.avatar});
  162. }
  163. if((user.user_name_view || null) != null) {
  164. this.setData({"nickname": user.user_name_view});
  165. }
  166. },
  167. // 获取数据
  168. get_data() {
  169. uni.request({
  170. url: app.globalData.get_request_url("index", "vip", "membershiplevelvip"),
  171. method: 'POST',
  172. data: {},
  173. dataType: 'json',
  174. success: res => {
  175. uni.stopPullDownRefresh();
  176. if (res.data.code == 0) {
  177. var data = res.data.data;
  178. this.setData({
  179. data_base: data.base || null,
  180. user_vip: data.user_vip || null,
  181. nav_list: data.nav_list || [],
  182. data_list_loding_msg: '',
  183. data_list_loding_status: 0,
  184. data_bottom_line_status: false
  185. });
  186. } else {
  187. this.setData({
  188. data_bottom_line_status: false,
  189. data_list_loding_status: 2,
  190. data_list_loding_msg: res.data.msg
  191. });
  192. if (app.globalData.is_login_check(res.data, this, 'get_data')) {
  193. app.globalData.showToast(res.data.msg);
  194. }
  195. }
  196. },
  197. fail: () => {
  198. uni.stopPullDownRefresh();
  199. this.setData({
  200. data_bottom_line_status: false,
  201. data_list_loding_status: 2,
  202. data_list_loding_msg: '服务器请求出错'
  203. });
  204. app.globalData.showToast('服务器请求出错');
  205. }
  206. });
  207. },
  208. // 头像查看
  209. preview_event() {
  210. if (app.globalData.data.default_user_head_src != this.avatar) {
  211. uni.previewImage({
  212. current: this.avatar,
  213. urls: [this.avatar]
  214. });
  215. }
  216. },
  217. // 头像加载错误
  218. user_avatar_error(e) {
  219. this.setData({
  220. avatar: app.globalData.data.default_user_head_src
  221. });
  222. },
  223. // 连续开通会员事件
  224. uservip_renew_event(e) {
  225. var self = this;
  226. uni.showModal({
  227. title: '温馨提示',
  228. content: '按照原时长和费用续费,确定继续吗?',
  229. confirmText: '确认',
  230. cancelText: '暂不',
  231. success: result => {
  232. if (result.confirm) {
  233. // 请求生成支付订单
  234. self.setData({
  235. submit_disabled_status: true
  236. });
  237. uni.showLoading({
  238. title: '处理中...'
  239. });
  240. uni.request({
  241. url: app.globalData.get_request_url("renew", "buy", "membershiplevelvip"),
  242. method: 'POST',
  243. data: {},
  244. dataType: 'json',
  245. success: res => {
  246. uni.hideLoading();
  247. self.setData({
  248. submit_disabled_status: false
  249. });
  250. if (res.data.code == 0) {
  251. uni.setStorageSync(app.globalData.data.cache_page_pay_key, res.data.data.id);
  252. uni.redirectTo({
  253. url: '/pages/plugins/membershiplevelvip/order/order'
  254. });
  255. } else {
  256. if (app.globalData.is_login_check(res.data, self, 'uservip_renew_event')) {
  257. app.globalData.showToast(res.data.msg);
  258. }
  259. }
  260. },
  261. fail: () => {
  262. self.setData({
  263. submit_disabled_status: false
  264. });
  265. uni.hideLoading();
  266. app.globalData.showToast('服务器请求出错');
  267. }
  268. });
  269. }
  270. }
  271. });
  272. }
  273. }
  274. };
  275. </script>
  276. <style>
  277. @import './user.css';
  278. </style>