index.vue 13 KB

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