index.vue 12 KB

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