index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="pageInfo.picture" mode="widthFix"></image>
  4. <view class="share-box">
  5. <!-- <view>分销商分享给好友,好友购买产品成功后即可获</view>
  6. <view>得分享奖励</view>
  7. <view>单笔最高可赚¥200.00</view>
  8. <view>快去分享吧</view> -->
  9. <u-parse :content="pageInfo.sharecontent"></u-parse>
  10. <button type="default" @click.stop='showShareModal'>分享</button>
  11. </view>
  12. <view class="share-box" style="height: 200upx;margin-top: 2%;" @longpress="copyCode">
  13. <view>长按复制框内整段文字,打开 [手淘] 即可购买</view>
  14. <view>{{pageInfo.copycontent}}</view>
  15. <button type="default" @click="copyCode">一键复制</button>
  16. </view>
  17. <view class="product-title">推荐产品</view>
  18. <!-- <view class="recommend-box">
  19. <view class="product-box" v-for="item in productList" :key="item.id" @click="goDetail(item.id)">
  20. <image :src="item.imgUrl"></image>
  21. <view class="detail-box">
  22. <view>{{item.productTitle}}</view>
  23. <view style="color: #999;">¥{{item.price}}</view>
  24. </view>
  25. </view>
  26. </view> -->
  27. <!-- <section class="PullScroll-Page"> -->
  28. <!-- <s-pull-scroll ref="pullScroll" :back-top="true" :pullDown="pullDown" :pullUp="loadData"> -->
  29. <view class="recommend-box">
  30. <view class="product-box" v-for="item in productList" :key="item.id" @click="goDetail(item.id)">
  31. <image :src="item.picture" mode='aspectFill'></image>
  32. <view class="detail-box">
  33. <view class='product-font'>{{item.desc || '-'}}</view>
  34. <view style="color: #999;">¥{{item.money || '-'}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- </s-pull-scroll> -->
  39. <!-- </section> -->
  40. <uni-popup ref="popup" type="bottom">
  41. <view class="uni-share">
  42. <view class="uni-share-content">
  43. <button class="uni-share-content-box" open-type="share">
  44. <view class="uni-share-content-image"><image src="/static/userSetIcon.png" class="image" /></view>
  45. <view class="uni-share-content-text">分享给好友</view>
  46. </button>
  47. <button class="uni-share-content-box" @click="goPostShare">
  48. <view class="uni-share-content-image"><image src="/static/share-icon1.png" class="image" /></view>
  49. <view class="uni-share-content-text">海报分享</view>
  50. </button>
  51. <button class="uni-share-content-box" @click="goRuleList">
  52. <view class="uni-share-content-image"><image src="/static/note.png" class="image" /></view>
  53. <view class="uni-share-content-text">分享规则</view>
  54. </button>
  55. </view>
  56. <view class="uni-share-btn" @click="cancelModal()">取消</view>
  57. </view>
  58. </uni-popup>
  59. </view>
  60. </template>
  61. <script>
  62. var md5 = require("../../common/md5.js");
  63. import uniPopup from "@/components/uni-popup/uni-popup.vue";
  64. import uParse from '@/components/gaoyia-parse/parse.vue'
  65. //import sPullScroll from '@/components/s-pull-scroll';
  66. export default {
  67. components: {
  68. uniPopup,
  69. uParse
  70. // sPullScroll
  71. },
  72. data() {
  73. return {
  74. title: 'Hello',
  75. pageInfo:{},
  76. isAuth:getApp().globalData.isAuth,
  77. productList:[
  78. {
  79. id:'1',
  80. imgUrl:'/static/bed-bg.png',
  81. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  82. price:'13999'
  83. },
  84. {
  85. id:'2',
  86. imgUrl:'/static/bed2-bg.png',
  87. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  88. price:'15999'
  89. },
  90. {
  91. id:'3',
  92. imgUrl:'/static/bed-bg.png',
  93. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  94. price:'16999'
  95. },
  96. {
  97. id:'4',
  98. imgUrl:'/static/bed2-bg.png',
  99. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  100. price:'18999'
  101. }
  102. ]
  103. }
  104. },
  105. onLoad(options) {
  106. //this.refresh();
  107. getApp().globalData.lastId = options.inviteId ? options.inviteId : getApp().globalData.user_id
  108. this.loginRequest();
  109. this.getPageProductList();
  110. },
  111. onShow() {
  112. this.isAuth =getApp().globalData.isAuth;
  113. },
  114. onShareAppMessage() {
  115. return {
  116. title: '分销小助手',
  117. path:'/pages/index/index?inviteId=' + getApp().globalData.user_id
  118. }
  119. },
  120. methods: {
  121. loginRequest(){
  122. uni.login({
  123. success: (res) => {
  124. uni.request({
  125. url: getApp().globalData.shareUrl, //需要设置为全局
  126. method: 'POST',
  127. header: {
  128. 'content-type': 'application/x-www-form-urlencoded'
  129. },
  130. data: {
  131. method: 'login',
  132. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  133. code: res.code,
  134. sign: md5('login' + getApp().globalData.globalTimestamp)
  135. },
  136. success: res => {
  137. // 通过openid发起会员登录
  138. console.log('userId',res.data.msg.id)
  139. getApp().globalData.user_id = res.data.msg.id;
  140. getApp().globalData.open_id = res.data.msg.openid;
  141. getApp().globalData.isAuth = res.data.msg.auth_status === '1';
  142. getApp().globalData.user_name = res.data.msg.name;
  143. getApp().globalData.user_headUrl = res.data.msg.headimg;
  144. getApp().globalData.session_key = res.data.msg.session_key;
  145. getApp().globalData.user_phone = res.data.msg.phone;
  146. getApp().globalData.user_status = res.data.msg.status;
  147. // getApp().globalData.times = res.data.msg.times;
  148. // getApp().globalData.total_times = res.data.msg.total_times;
  149. this.isAuth = getApp().globalData.isAuth;
  150. this.getPageInfo(res.data.msg.id);
  151. }
  152. });
  153. }
  154. });
  155. },
  156. getPageInfo(uId){ //获取首页面基本信息接口
  157. uni.showLoading({
  158. title: '加载中',
  159. });
  160. let that = this;
  161. uni.request({
  162. url: getApp().globalData.shareUrl, //需要设置为全局
  163. method: 'POST',
  164. header: {
  165. 'content-type': 'application/x-www-form-urlencoded'
  166. },
  167. data: {
  168. method: 'getHomePageInfo',
  169. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  170. id: 1,
  171. sign: md5('getHomePageInfo' + getApp().globalData.globalTimestamp)
  172. },
  173. success: res => {
  174. if (res.data.code === 200) {
  175. uni.hideLoading();
  176. that.pageInfo = res.data.msg;
  177. getApp().globalData.shareImg = res.data.msg.picture;
  178. getApp().globalData.shareContent = res.data.msg.sharecontent;
  179. getApp().globalData.shareTaobaoCode = res.data.msg.copycontent;
  180. console.log(res.data.msg)
  181. }
  182. }
  183. });
  184. },
  185. getPageProductList(pullScroll){ //获取首页面产品列表接口
  186. let that = this;
  187. uni.request({
  188. url: getApp().globalData.shareUrl, //需要设置为全局
  189. method: 'POST',
  190. header: {
  191. 'content-type': 'application/x-www-form-urlencoded'
  192. },
  193. data: {
  194. method: 'getProductsList',
  195. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  196. // page: pullScroll.page,
  197. // pageSize:4,
  198. page:'',
  199. pageSize:'',
  200. sign: md5('getProductsList' + getApp().globalData.globalTimestamp)
  201. },
  202. success: res => {
  203. if (res.data.code === 200) {
  204. console.log(res.data.msg)
  205. that.productList = res.data.msg;
  206. // setTimeout(() => {
  207. // if (pullScroll.page == 1) {
  208. // this.productList = res.data.msg;
  209. // }
  210. // const curList = [];
  211. // for (let i = res.data.msg.length; i < res.data.msg.length + 4; i++) {
  212. // curList.push(i);
  213. // }
  214. // this.productList = this.productList.concat(curList);
  215. // if (this.productList.length > 60) {
  216. // // finish(boolean:是否显示finishText,默认显示)
  217. // pullScroll.finish(this.productList.length > 4);
  218. // } else {
  219. // pullScroll.success();
  220. // }
  221. // }, 500);
  222. }
  223. }
  224. });
  225. },
  226. showShareModal(){
  227. // 需要在 popup 组件,指定 ref 为 popup
  228. if(!this.isAuth){
  229. uni.navigateTo({
  230. url: '../auth/index',
  231. success: res => {},
  232. fail: () => {},
  233. complete: () => {}
  234. });
  235. }else {
  236. this.$refs.popup.open();
  237. }
  238. },
  239. cancelModal(){
  240. // 需要在 popup 组件,指定 ref 为 popup
  241. this.$refs.popup.close();
  242. },
  243. goPostShare() {
  244. this.$refs.popup.close()
  245. uni.navigateTo({
  246. url: '/pages/index/postShare/index'
  247. })
  248. },
  249. goDetail(id){
  250. uni.navigateTo({
  251. url: '/pages/index/detailPage/index?detailId='+id,
  252. success: res => {},
  253. fail: () => {},
  254. complete: () => {}
  255. });
  256. },
  257. goRuleList(){
  258. uni.navigateTo({
  259. url: '/pages/index/ruleList/index',
  260. success: res => {},
  261. fail: () => {},
  262. complete: () => {}
  263. });
  264. },
  265. copyCode(){
  266. let that = this;
  267. if(!that.isAuth){
  268. uni.navigateTo({
  269. url: '../auth/index',
  270. success: res => {},
  271. fail: () => {},
  272. complete: () => {}
  273. });
  274. }else {
  275. uni.setClipboardData({
  276. data:that.pageInfo.copycontent,
  277. success() {
  278. uni.showToast({
  279. icon:'none',
  280. title:'复制成功'
  281. })
  282. }
  283. })
  284. }
  285. },
  286. refresh () {
  287. this.$nextTick(() => {
  288. this.$refs.pullScroll.refresh();
  289. });
  290. },
  291. pullDown (pullScroll) {
  292. setTimeout(() => {
  293. this.loadData(pullScroll);
  294. }, 200);
  295. },
  296. loadData (pullScroll) {
  297. this.getPageProductList(pullScroll)
  298. }
  299. }
  300. }
  301. </script>
  302. <style lang="scss">
  303. // @import url("../../../components/gaoyia-parse/parse.css");
  304. // .PullScroll-Page {
  305. // padding: 40rpx;
  306. // .btn {
  307. // width: 100%;
  308. // height: 80rpx;
  309. // font-size: 28rpx;
  310. // &:not(:first-child) {
  311. // margin-top: 40rpx;
  312. // }
  313. // }
  314. // }
  315. .content {
  316. display: flex;
  317. flex-direction: column;
  318. align-items: center;
  319. justify-content: center;
  320. }
  321. .logo {
  322. // height: 400px;
  323. width: 100%;
  324. margin-bottom: 30upx;
  325. }
  326. .share-box {
  327. display: flex;
  328. flex-direction: column;
  329. justify-content: center;
  330. align-items: center;
  331. width: 80%;
  332. height: 300upx;
  333. border: 1px dashed red;
  334. background: #fff;
  335. font-size: 28rpx;
  336. padding: 5px;
  337. }
  338. .share-box button {
  339. width: 300rpx;
  340. height: 70rpx;
  341. line-height: 70rpx;
  342. margin-top: 2%;
  343. background-color: #27BCEF;
  344. color: #fff;
  345. }
  346. .title {
  347. font-size: 36upx;
  348. color: #8f8f94;
  349. }
  350. .product-title {
  351. margin-left: -75%;
  352. margin-top: 5%;
  353. margin-bottom: 1%;
  354. }
  355. .product-font {
  356. display: -webkit-box;
  357. overflow: hidden;
  358. text-overflow: ellipsis;
  359. word-wrap: break-word;
  360. white-space: normal !important;
  361. -webkit-line-clamp: 3;
  362. -webkit-box-orient: vertical;
  363. font-size: 14px;
  364. }
  365. .recommend-box {
  366. width: 95%;
  367. display: flex;
  368. flex-direction: column;
  369. justify-content: center;
  370. align-items: center;
  371. }
  372. .product-box {
  373. width: 90%;
  374. height: 200rpx;
  375. padding: 20rpx;
  376. display: flex;
  377. align-items: center;
  378. background-color: #fff;
  379. border-radius:10px;
  380. margin-bottom: 2%;
  381. }
  382. .product-box image {
  383. width: 40%!important;
  384. height: 180rpx;
  385. margin-right: 5%;
  386. }
  387. .detail-box {
  388. width: 60%!important;
  389. display: flex;
  390. flex-direction: column;
  391. justify-content: space-between;
  392. font-size: 30rpx;
  393. height: 190rpx;
  394. }
  395. //分享模态框
  396. .uni-share-content {
  397. display: flex;
  398. flex-wrap: wrap;
  399. padding: 15px;
  400. /* justify-content: center */
  401. }
  402. .uni-share-content-box {
  403. display: flex;
  404. flex-direction: column;
  405. align-items: center;
  406. width: 25%;
  407. box-sizing: border-box;
  408. margin-left: 0;
  409. margin-right: 0;
  410. border: none;
  411. background: transparent;
  412. padding-left: 0;
  413. padding-right: 0;
  414. }
  415. .uni-share-content-box::after{
  416. border: none;
  417. }
  418. .uni-share-content-image {
  419. display: flex;
  420. justify-content: center;
  421. align-items: center;
  422. width: 60upx;
  423. height: 60upx;
  424. overflow: hidden;
  425. border-radius: 10upx;
  426. }
  427. .uni-share-content-image .image {
  428. width: 100%;
  429. height: 100%;
  430. }
  431. .uni-share-content-text {
  432. font-size: 26upx;
  433. color: #999;
  434. padding-top: 5px;
  435. // padding-bottom: 10px;
  436. }
  437. .uni-share-btn {
  438. height: 90upx;
  439. line-height: 90upx;
  440. border-top: 1px #f5f5f5 solid;
  441. text-align: center;
  442. color: #666;
  443. font-size: 30rpx;
  444. }
  445. </style>