recommend.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view>
  3. <image mode="widthFix" src="https://6a7a-jzmall-3gi3t6y452ddb0ff-1306484940.tcb.qcloud.la/referee/top-banner.png" class="top-banner"></image>
  4. <!-- 头像 -->
  5. <view class="avatar-block">
  6. <view class="avatar-wrapper">
  7. <image :src="avatarUrl" class="user-avatar" mode="aspectFill"></image>
  8. </view>
  9. </view>
  10. <view class="user-name">{{ userName }}</view>
  11. <view class="jz-slogan">邀您加入鲸致生活,一起放手精致</view>
  12. <button class="recommend-btn" v-if="rid != 0 && checked" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">一键成为引荐人</button>
  13. <button class="recommend-btn" v-if="rid != 0 && !checked" @tap="confirmJoin">一键成为引荐人</button>
  14. <view class="agree-terms">
  15. <van-checkbox :value="checked" shape="square" icon-size="16px" checked-color="#09afff" @change="onChange"></van-checkbox>
  16. <text class="user-agree">我已同意</text>
  17. <text class="user-terms" ontap="userProtocol">《用户条款》</text>
  18. </view>
  19. <view class="adv-block">
  20. <view class="adv-item">
  21. <text class="adv-word">省</text>
  22. <text class="adv-text">自用鲸致家政</text>
  23. </view>
  24. <view class="adv-item">
  25. <text class="adv-word">赚</text>
  26. <text class="adv-text">推荐亲友使用</text>
  27. </view>
  28. <view class="adv-item">
  29. <text class="adv-word">棒</text>
  30. <text class="adv-text">品牌好品质优</text>
  31. </view>
  32. </view>
  33. <van-dialog id="van-dialog" />
  34. </view>
  35. </template>
  36. <script>
  37. import Dialog from '@vant/weapp/lib/dialog/dialog';
  38. const util = require('../../../../utils/util.js');
  39. const api = require('../../../../config/api.js');
  40. const user = require('../../../../utils/user.js');
  41. const app = getApp();
  42. export default {
  43. data() {
  44. return {
  45. rId: 0,
  46. checked: false,
  47. userName: '',
  48. loginCode: '',
  49. avatarUrl: '',
  50. bCode: '',
  51. userName: '',
  52. avatarUrl: '',
  53. detail: '',
  54. rid: 0
  55. };
  56. }
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */,
  60. onLoad: function (options) {
  61. if (options.rId) {
  62. this.setData({
  63. rId: options.rId
  64. });
  65. app.globalData.rId = options.rId;
  66. this.getReferrerRidInfo();
  67. }
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady: function () {},
  73. /**
  74. * 生命周期函数--监听页面显示
  75. */
  76. onShow: function () {
  77. this.getLoginCode();
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function () {},
  83. /**
  84. * 生命周期函数--监听页面卸载
  85. */
  86. onUnload: function () {},
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {},
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom: function () {},
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {},
  99. methods: {
  100. getReferrerRidInfo() {
  101. util.request(
  102. api.ReferrerRidInfo,
  103. {
  104. rId: this.rId
  105. },
  106. 'GET'
  107. ).then((res) => {
  108. console.info(res);
  109. if (res.errno == 0) {
  110. this.setData({
  111. userName: res.data.applyName,
  112. avatarUrl: res.data.avatar,
  113. userName: res.data.applyName,
  114. avatarUrl: res.data.avatar,
  115. bCode: res.data.bCode
  116. });
  117. } else {
  118. util.showErrorToast(res.errmsg);
  119. }
  120. });
  121. },
  122. getPhoneNumber(e) {
  123. console.info(e);
  124. this.setData({
  125. detail: e.detail
  126. });
  127. this.getDenPhone();
  128. },
  129. getDenPhone() {
  130. let that = this;
  131. util.request(
  132. api.GetDenPhone,
  133. {
  134. code: that.loginCode,
  135. encryptedData: that.detail.encryptedData,
  136. errMsg: that.detail.errMsg,
  137. iv: that.detail.iv
  138. },
  139. 'POST'
  140. ).then((res) => {
  141. if (res.errno == 0) {
  142. let isNew = res.data.isNew;
  143. if (isNew) {
  144. app.globalData.recommend.phone = res.data.phone;
  145. app.globalData.recommend.unionId = res.data.unionId;
  146. app.globalData.recommend.openId = res.data.openId;
  147. app.globalData.recommend.sessionKey = res.data.sessionKey;
  148. uni.navigateTo({
  149. url: '../register/register'
  150. });
  151. } else {
  152. // 不是新人,则跳转到首页
  153. Dialog.alert({
  154. title: '引荐失败',
  155. message: '您已是鲸致商城用户,当前引荐人计划只面向新用户,敬请期待'
  156. }).then(() => {
  157. // on close
  158. uni.switchTab({
  159. url: '/pages/index/index'
  160. });
  161. });
  162. }
  163. } else {
  164. util.showErrorToast(res.errmsg);
  165. this.getLoginCode();
  166. }
  167. });
  168. },
  169. getLoginCode() {
  170. let that = this;
  171. user.login().then((res) => {
  172. that.setData({
  173. loginCode: res.code
  174. });
  175. });
  176. },
  177. onChange(e) {
  178. console.log(e);
  179. this.setData({
  180. checked: e.detail
  181. });
  182. },
  183. confirmJoin() {
  184. if (!this.checked) {
  185. Dialog.alert({
  186. title: '提示',
  187. message: '请阅读《用户条款》并勾选'
  188. }).then(() => {
  189. // on close
  190. });
  191. } else {
  192. uni.navigateTo({
  193. url: '../confirm/confirm'
  194. });
  195. }
  196. },
  197. userProtocol() {
  198. uni.navigateTo({
  199. url: '../protocol/protocol'
  200. });
  201. }
  202. }
  203. };
  204. </script>
  205. <style>
  206. .top-banner {
  207. width: 100%;
  208. }
  209. button::after {
  210. border: none;
  211. }
  212. .avatar-block {
  213. height: 156rpx;
  214. margin: -78rpx 0 58rpx;
  215. text-align: center;
  216. width: 100%;
  217. display: flex;
  218. justify-content: center;
  219. }
  220. .recommend-btn {
  221. background: url('https://jzmall.lifejingzhi.com/file/jzmall/weixin/btn.png') no-repeat center;
  222. background-size: 100%;
  223. width: 592rpx;
  224. height: 114rpx;
  225. margin: 0 auto;
  226. color: #fff;
  227. font-size: 36rpx;
  228. line-height: 114rpx;
  229. text-align: center;
  230. font-weight: bold;
  231. }
  232. .avatar-wrapper {
  233. padding: 6rpx;
  234. width: 156rpx;
  235. height: 156rpx;
  236. background: #fff;
  237. border-radius: 100%;
  238. }
  239. .user-avatar {
  240. width: 146rpx;
  241. height: 146rpx;
  242. border-radius: 100%;
  243. }
  244. .user-name {
  245. color: #2a2a2a;
  246. font-size: 40rpx;
  247. font-weight: bold;
  248. text-align: center;
  249. }
  250. .jz-slogan {
  251. color: #2a2a2a;
  252. font-size: 32rpx;
  253. margin: 30rpx 0 40rpx;
  254. text-align: center;
  255. height: 32rpx;
  256. }
  257. .agree-terms {
  258. margin: 30rpx 0 104rpx;
  259. height: 26rpx;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. }
  264. .user-agree {
  265. color: #85868a;
  266. font-size: 24rpx;
  267. margin-left: 8rpx;
  268. }
  269. .user-terms {
  270. color: #cc4226;
  271. font-size: 24rpx;
  272. }
  273. .adv-block {
  274. display: flex;
  275. padding: 40rpx 24rpx 80rpx;
  276. justify-content: space-between;
  277. }
  278. .adv-item {
  279. background: url('https://jzmall.lifejingzhi.com/file/jzmall/weixin/tag-bg.png') no-repeat center;
  280. background-size: 100%;
  281. height: 126rpx;
  282. width: 212rpx;
  283. padding: 24rpx 0 14rpx;
  284. display: flex;
  285. flex-direction: column;
  286. align-items: center;
  287. justify-content: space-between;
  288. }
  289. .adv-word {
  290. font-size: 34rpx;
  291. line-height: 34rpx;
  292. color: white;
  293. }
  294. .adv-text {
  295. font-size: 24rpx;
  296. color: #2a2a2a;
  297. }
  298. </style>