index.vue 12 KB

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