index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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. getShareInfo(uid){
  123. uni.request({
  124. url: getApp().globalData.shareUrl, //需要设置为全局
  125. method: 'POST',
  126. header: {
  127. 'content-type': 'application/x-www-form-urlencoded'
  128. },
  129. data: {
  130. method: 'addShare',
  131. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  132. shangjiid:getApp().globalData.lastId || uid,
  133. userid:uid,
  134. sign: md5('addShare' + getApp().globalData.globalTimestamp)
  135. },
  136. success: res => {
  137. console.log(res)
  138. }
  139. });
  140. },
  141. loginRequest(){
  142. uni.login({
  143. success: (res) => {
  144. uni.request({
  145. url: getApp().globalData.shareUrl, //需要设置为全局
  146. method: 'POST',
  147. header: {
  148. 'content-type': 'application/x-www-form-urlencoded'
  149. },
  150. data: {
  151. method: 'login',
  152. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  153. code: res.code,
  154. sign: md5('login' + getApp().globalData.globalTimestamp)
  155. },
  156. success: res => {
  157. // 通过openid发起会员登录
  158. console.log('userId',res.data.msg.id)
  159. getApp().globalData.user_id = res.data.msg.id;
  160. getApp().globalData.open_id = res.data.msg.openid;
  161. getApp().globalData.isAuth = res.data.msg.auth_status === '1';
  162. getApp().globalData.user_name = res.data.msg.name;
  163. getApp().globalData.user_headUrl = res.data.msg.headimg;
  164. getApp().globalData.session_key = res.data.msg.session_key;
  165. getApp().globalData.user_phone = res.data.msg.phone;
  166. getApp().globalData.user_status = res.data.msg.status;
  167. // getApp().globalData.times = res.data.msg.times;
  168. // getApp().globalData.total_times = res.data.msg.total_times;
  169. this.isAuth = getApp().globalData.isAuth;
  170. this.getPageInfo(res.data.msg.id);
  171. this.getShareInfo(res.data.msg.id)
  172. }
  173. });
  174. }
  175. });
  176. },
  177. getPageInfo(uId){ //获取首页面基本信息接口
  178. uni.showLoading({
  179. title: '加载中',
  180. });
  181. let that = this;
  182. uni.request({
  183. url: getApp().globalData.shareUrl, //需要设置为全局
  184. method: 'POST',
  185. header: {
  186. 'content-type': 'application/x-www-form-urlencoded'
  187. },
  188. data: {
  189. method: 'getHomePageInfo',
  190. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  191. id: 1,
  192. sign: md5('getHomePageInfo' + getApp().globalData.globalTimestamp)
  193. },
  194. success: res => {
  195. if (res.data.code === 200) {
  196. uni.hideLoading();
  197. that.pageInfo = res.data.msg;
  198. getApp().globalData.shareImg = res.data.msg.picture;
  199. getApp().globalData.shareContent = res.data.msg.sharecontent;
  200. getApp().globalData.shareTaobaoCode = res.data.msg.copycontent;
  201. getApp().globalData.shareStoreImg = res.data.msg.heading;
  202. }
  203. }
  204. });
  205. },
  206. getPageProductList(pullScroll){ //获取首页面产品列表接口
  207. let that = this;
  208. uni.request({
  209. url: getApp().globalData.shareUrl, //需要设置为全局
  210. method: 'POST',
  211. header: {
  212. 'content-type': 'application/x-www-form-urlencoded'
  213. },
  214. data: {
  215. method: 'getProductsList',
  216. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  217. // page: pullScroll.page,
  218. // pageSize:4,
  219. page:'',
  220. pageSize:'',
  221. sign: md5('getProductsList' + getApp().globalData.globalTimestamp)
  222. },
  223. success: res => {
  224. if (res.data.code === 200) {
  225. console.log(res.data.msg)
  226. that.productList = res.data.msg;
  227. // setTimeout(() => {
  228. // if (pullScroll.page == 1) {
  229. // this.productList = res.data.msg;
  230. // }
  231. // const curList = [];
  232. // for (let i = res.data.msg.length; i < res.data.msg.length + 4; i++) {
  233. // curList.push(i);
  234. // }
  235. // this.productList = this.productList.concat(curList);
  236. // if (this.productList.length > 60) {
  237. // // finish(boolean:是否显示finishText,默认显示)
  238. // pullScroll.finish(this.productList.length > 4);
  239. // } else {
  240. // pullScroll.success();
  241. // }
  242. // }, 500);
  243. }
  244. }
  245. });
  246. },
  247. showShareModal(){
  248. // 需要在 popup 组件,指定 ref 为 popup
  249. if(!this.isAuth){
  250. uni.navigateTo({
  251. url: '../auth/index',
  252. success: res => {},
  253. fail: () => {},
  254. complete: () => {}
  255. });
  256. }else {
  257. this.$refs.popup.open();
  258. }
  259. },
  260. cancelModal(){
  261. // 需要在 popup 组件,指定 ref 为 popup
  262. this.$refs.popup.close();
  263. },
  264. goPostShare() {
  265. this.$refs.popup.close()
  266. uni.navigateTo({
  267. url: '/pages/index/postShare/index'
  268. })
  269. },
  270. goDetail(id){
  271. uni.navigateTo({
  272. url: '/pages/index/detailPage/index?detailId='+id,
  273. success: res => {},
  274. fail: () => {},
  275. complete: () => {}
  276. });
  277. },
  278. goRuleList(){
  279. uni.navigateTo({
  280. url: '/pages/index/ruleList/index',
  281. success: res => {},
  282. fail: () => {},
  283. complete: () => {}
  284. });
  285. },
  286. copyCode(){
  287. let that = this;
  288. if(!that.isAuth){
  289. uni.navigateTo({
  290. url: '../auth/index',
  291. success: res => {},
  292. fail: () => {},
  293. complete: () => {}
  294. });
  295. }else {
  296. uni.setClipboardData({
  297. data:that.pageInfo.copycontent,
  298. success() {
  299. uni.showToast({
  300. icon:'none',
  301. title:'复制成功'
  302. })
  303. }
  304. })
  305. }
  306. },
  307. refresh () {
  308. this.$nextTick(() => {
  309. this.$refs.pullScroll.refresh();
  310. });
  311. },
  312. pullDown (pullScroll) {
  313. setTimeout(() => {
  314. this.loadData(pullScroll);
  315. }, 200);
  316. },
  317. loadData (pullScroll) {
  318. this.getPageProductList(pullScroll)
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss">
  324. // @import url("../../../components/gaoyia-parse/parse.css");
  325. // .PullScroll-Page {
  326. // padding: 40rpx;
  327. // .btn {
  328. // width: 100%;
  329. // height: 80rpx;
  330. // font-size: 28rpx;
  331. // &:not(:first-child) {
  332. // margin-top: 40rpx;
  333. // }
  334. // }
  335. // }
  336. .content {
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. justify-content: center;
  341. }
  342. .logo {
  343. // height: 400px;
  344. width: 100%;
  345. margin-bottom: 30upx;
  346. }
  347. .share-box {
  348. display: flex;
  349. flex-direction: column;
  350. justify-content: center;
  351. align-items: center;
  352. width: 80%;
  353. height: 300upx;
  354. border: 1px dashed red;
  355. background: #fff;
  356. font-size: 28rpx;
  357. padding: 5px;
  358. }
  359. .share-box button {
  360. width: 300rpx;
  361. height: 70rpx;
  362. line-height: 70rpx;
  363. margin-top: 2%;
  364. background-color: #27BCEF;
  365. color: #fff;
  366. }
  367. .title {
  368. font-size: 36upx;
  369. color: #8f8f94;
  370. }
  371. .product-title {
  372. margin-left: -75%;
  373. margin-top: 5%;
  374. margin-bottom: 1%;
  375. }
  376. .product-font {
  377. display: -webkit-box;
  378. overflow: hidden;
  379. text-overflow: ellipsis;
  380. word-wrap: break-word;
  381. white-space: normal !important;
  382. -webkit-line-clamp: 3;
  383. -webkit-box-orient: vertical;
  384. font-size: 14px;
  385. }
  386. .recommend-box {
  387. width: 95%;
  388. display: flex;
  389. flex-direction: column;
  390. justify-content: center;
  391. align-items: center;
  392. }
  393. .product-box {
  394. width: 90%;
  395. height: 200rpx;
  396. padding: 20rpx;
  397. display: flex;
  398. align-items: center;
  399. background-color: #fff;
  400. border-radius:10px;
  401. margin-bottom: 2%;
  402. }
  403. .product-box image {
  404. width: 40%!important;
  405. height: 180rpx;
  406. margin-right: 5%;
  407. }
  408. .detail-box {
  409. width: 60%!important;
  410. display: flex;
  411. flex-direction: column;
  412. justify-content: space-between;
  413. font-size: 30rpx;
  414. height: 190rpx;
  415. }
  416. //分享模态框
  417. .uni-share-content {
  418. display: flex;
  419. flex-wrap: wrap;
  420. padding: 15px;
  421. /* justify-content: center */
  422. }
  423. .uni-share-content-box {
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. width: 25%;
  428. box-sizing: border-box;
  429. margin-left: 0;
  430. margin-right: 0;
  431. border: none;
  432. background: transparent;
  433. padding-left: 0;
  434. padding-right: 0;
  435. }
  436. .uni-share-content-box::after{
  437. border: none;
  438. }
  439. .uni-share-content-image {
  440. display: flex;
  441. justify-content: center;
  442. align-items: center;
  443. width: 60upx;
  444. height: 60upx;
  445. overflow: hidden;
  446. border-radius: 10upx;
  447. }
  448. .uni-share-content-image .image {
  449. width: 100%;
  450. height: 100%;
  451. }
  452. .uni-share-content-text {
  453. font-size: 26upx;
  454. color: #999;
  455. padding-top: 5px;
  456. // padding-bottom: 10px;
  457. }
  458. .uni-share-btn {
  459. height: 90upx;
  460. line-height: 90upx;
  461. border-top: 1px #f5f5f5 solid;
  462. text-align: center;
  463. color: #666;
  464. font-size: 30rpx;
  465. }
  466. </style>