index.vue 13 KB

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