index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="pageInfo.picture"></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"></image>
  32. <view class="detail-box">
  33. <view>{{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. uni.setClipboardData({
  256. data:that.pageInfo.copycontent,
  257. success() {
  258. uni.showToast({
  259. icon:'none',
  260. title:'复制成功'
  261. })
  262. }
  263. })
  264. },
  265. refresh () {
  266. this.$nextTick(() => {
  267. this.$refs.pullScroll.refresh();
  268. });
  269. },
  270. pullDown (pullScroll) {
  271. setTimeout(() => {
  272. this.loadData(pullScroll);
  273. }, 200);
  274. },
  275. loadData (pullScroll) {
  276. this.getPageProductList(pullScroll)
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss">
  282. // @import url("../../../components/gaoyia-parse/parse.css");
  283. // .PullScroll-Page {
  284. // padding: 40rpx;
  285. // .btn {
  286. // width: 100%;
  287. // height: 80rpx;
  288. // font-size: 28rpx;
  289. // &:not(:first-child) {
  290. // margin-top: 40rpx;
  291. // }
  292. // }
  293. // }
  294. .content {
  295. display: flex;
  296. flex-direction: column;
  297. align-items: center;
  298. justify-content: center;
  299. }
  300. .logo {
  301. height: 400px;
  302. width: 100%;
  303. margin-bottom: 30upx;
  304. }
  305. .share-box {
  306. display: flex;
  307. flex-direction: column;
  308. justify-content: center;
  309. align-items: center;
  310. width: 80%;
  311. height: 300upx;
  312. border: 1px dashed red;
  313. background: #fff;
  314. font-size: 28rpx;
  315. padding: 5px;
  316. }
  317. .share-box button {
  318. width: 300rpx;
  319. height: 70rpx;
  320. line-height: 70rpx;
  321. margin-top: 2%;
  322. background-color: #27BCEF;
  323. color: #fff;
  324. }
  325. .title {
  326. font-size: 36upx;
  327. color: #8f8f94;
  328. }
  329. .product-title {
  330. margin-left: -75%;
  331. margin-top: 5%;
  332. margin-bottom: 1%;
  333. }
  334. .recommend-box {
  335. width: 95%;
  336. display: flex;
  337. flex-direction: column;
  338. justify-content: center;
  339. align-items: center;
  340. }
  341. .product-box {
  342. width: 90%;
  343. height: 200rpx;
  344. padding: 20rpx;
  345. display: flex;
  346. align-items: center;
  347. background-color: #fff;
  348. border-radius:10px;
  349. margin-bottom: 2%;
  350. }
  351. .product-box image {
  352. width: 40%;
  353. height: 180rpx;
  354. margin-right: 5%;
  355. }
  356. .detail-box {
  357. display: flex;
  358. flex-direction: column;
  359. justify-content: space-between;
  360. font-size: 30rpx;
  361. height: 190rpx;
  362. }
  363. //分享模态框
  364. .uni-share-content {
  365. display: flex;
  366. flex-wrap: wrap;
  367. padding: 15px;
  368. /* justify-content: center */
  369. }
  370. .uni-share-content-box {
  371. display: flex;
  372. flex-direction: column;
  373. align-items: center;
  374. width: 25%;
  375. box-sizing: border-box;
  376. margin-left: 0;
  377. margin-right: 0;
  378. border: none;
  379. background: transparent;
  380. padding-left: 0;
  381. padding-right: 0;
  382. }
  383. .uni-share-content-box::after{
  384. border: none;
  385. }
  386. .uni-share-content-image {
  387. display: flex;
  388. justify-content: center;
  389. align-items: center;
  390. width: 60upx;
  391. height: 60upx;
  392. overflow: hidden;
  393. border-radius: 10upx;
  394. }
  395. .uni-share-content-image .image {
  396. width: 100%;
  397. height: 100%;
  398. }
  399. .uni-share-content-text {
  400. font-size: 26upx;
  401. color: #999;
  402. padding-top: 5px;
  403. // padding-bottom: 10px;
  404. }
  405. .uni-share-btn {
  406. height: 90upx;
  407. line-height: 90upx;
  408. border-top: 1px #f5f5f5 solid;
  409. text-align: center;
  410. color: #666;
  411. font-size: 30rpx;
  412. }
  413. </style>