index.vue 13 KB

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