index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. let that = this;
  154. uni.request({
  155. url: getApp().globalData.shareUrl, //需要设置为全局
  156. method: 'POST',
  157. header: {
  158. 'content-type': 'application/x-www-form-urlencoded'
  159. },
  160. data: {
  161. method: 'getHomePageInfo',
  162. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  163. id: uId,
  164. sign: md5('getHomePageInfo' + getApp().globalData.globalTimestamp)
  165. },
  166. success: res => {
  167. if (res.data.code === 200) {
  168. that.pageInfo = res.data.msg;
  169. getApp().globalData.shareImg = res.data.msg.picture;
  170. console.log(res.data.msg)
  171. }
  172. }
  173. });
  174. },
  175. getPageProductList(pullScroll){ //获取首页面产品列表接口
  176. let that = this;
  177. uni.request({
  178. url: getApp().globalData.shareUrl, //需要设置为全局
  179. method: 'POST',
  180. header: {
  181. 'content-type': 'application/x-www-form-urlencoded'
  182. },
  183. data: {
  184. method: 'getProductsList',
  185. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  186. // page: pullScroll.page,
  187. // pageSize:4,
  188. page:'',
  189. pageSize:'',
  190. sign: md5('getProductsList' + getApp().globalData.globalTimestamp)
  191. },
  192. success: res => {
  193. if (res.data.code === 200) {
  194. console.log(res.data.msg)
  195. that.productList = res.data.msg;
  196. // setTimeout(() => {
  197. // if (pullScroll.page == 1) {
  198. // this.productList = res.data.msg;
  199. // }
  200. // const curList = [];
  201. // for (let i = res.data.msg.length; i < res.data.msg.length + 4; i++) {
  202. // curList.push(i);
  203. // }
  204. // this.productList = this.productList.concat(curList);
  205. // if (this.productList.length > 60) {
  206. // // finish(boolean:是否显示finishText,默认显示)
  207. // pullScroll.finish(this.productList.length > 4);
  208. // } else {
  209. // pullScroll.success();
  210. // }
  211. // }, 500);
  212. }
  213. }
  214. });
  215. },
  216. showShareModal(){
  217. // 需要在 popup 组件,指定 ref 为 popup
  218. if(!this.isAuth){
  219. uni.navigateTo({
  220. url: '../auth/index',
  221. success: res => {},
  222. fail: () => {},
  223. complete: () => {}
  224. });
  225. }else {
  226. this.$refs.popup.open();
  227. }
  228. },
  229. cancelModal(){
  230. // 需要在 popup 组件,指定 ref 为 popup
  231. this.$refs.popup.close();
  232. },
  233. goPostShare() {
  234. this.$refs.popup.close()
  235. uni.navigateTo({
  236. url: '/pages/index/postShare/index'
  237. })
  238. },
  239. goDetail(id){
  240. uni.navigateTo({
  241. url: '/pages/index/detailPage/index?detailId='+id,
  242. success: res => {},
  243. fail: () => {},
  244. complete: () => {}
  245. });
  246. },
  247. copyCode(){
  248. uni.setClipboardData({
  249. data:'xxx',
  250. success() {
  251. uni.showToast({
  252. icon:'none',
  253. title:'复制成功'
  254. })
  255. }
  256. })
  257. },
  258. refresh () {
  259. this.$nextTick(() => {
  260. this.$refs.pullScroll.refresh();
  261. });
  262. },
  263. pullDown (pullScroll) {
  264. setTimeout(() => {
  265. this.loadData(pullScroll);
  266. }, 200);
  267. },
  268. loadData (pullScroll) {
  269. this.getPageProductList(pullScroll)
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="scss">
  275. // .PullScroll-Page {
  276. // padding: 40rpx;
  277. // .btn {
  278. // width: 100%;
  279. // height: 80rpx;
  280. // font-size: 28rpx;
  281. // &:not(:first-child) {
  282. // margin-top: 40rpx;
  283. // }
  284. // }
  285. // }
  286. .content {
  287. display: flex;
  288. flex-direction: column;
  289. align-items: center;
  290. justify-content: center;
  291. }
  292. .logo {
  293. height: 400px;
  294. width: 100%;
  295. margin-bottom: 30upx;
  296. }
  297. .share-box {
  298. display: flex;
  299. flex-direction: column;
  300. justify-content: center;
  301. align-items: center;
  302. width: 80%;
  303. height: 300upx;
  304. border: 1px dashed red;
  305. background: #fff;
  306. font-size: 28rpx;
  307. padding: 5px;
  308. }
  309. .share-box button {
  310. width: 300rpx;
  311. height: 70rpx;
  312. line-height: 70rpx;
  313. margin-top: 2%;
  314. background-color: #27BCEF;
  315. color: #fff;
  316. }
  317. .title {
  318. font-size: 36upx;
  319. color: #8f8f94;
  320. }
  321. .product-title {
  322. margin-left: -75%;
  323. margin-top: 5%;
  324. margin-bottom: 1%;
  325. }
  326. .recommend-box {
  327. width: 95%;
  328. display: flex;
  329. flex-direction: column;
  330. justify-content: center;
  331. align-items: center;
  332. }
  333. .product-box {
  334. width: 90%;
  335. height: 200rpx;
  336. padding: 20rpx;
  337. display: flex;
  338. align-items: center;
  339. background-color: #fff;
  340. border-radius:10px;
  341. margin-bottom: 2%;
  342. }
  343. .product-box image {
  344. width: 40%;
  345. height: 180rpx;
  346. margin-right: 5%;
  347. }
  348. .detail-box {
  349. display: flex;
  350. flex-direction: column;
  351. justify-content: space-between;
  352. font-size: 30rpx;
  353. height: 190rpx;
  354. }
  355. //分享模态框
  356. .uni-share-content {
  357. display: flex;
  358. flex-wrap: wrap;
  359. padding: 15px;
  360. /* justify-content: center */
  361. }
  362. .uni-share-content-box {
  363. display: flex;
  364. flex-direction: column;
  365. align-items: center;
  366. width: 25%;
  367. box-sizing: border-box;
  368. margin-left: 0;
  369. margin-right: 0;
  370. border: none;
  371. background: transparent;
  372. padding-left: 0;
  373. padding-right: 0;
  374. }
  375. .uni-share-content-box::after{
  376. border: none;
  377. }
  378. .uni-share-content-image {
  379. display: flex;
  380. justify-content: center;
  381. align-items: center;
  382. width: 60upx;
  383. height: 60upx;
  384. overflow: hidden;
  385. border-radius: 10upx;
  386. }
  387. .uni-share-content-image .image {
  388. width: 100%;
  389. height: 100%;
  390. }
  391. .uni-share-content-text {
  392. font-size: 26upx;
  393. color: #999;
  394. padding-top: 5px;
  395. // padding-bottom: 10px;
  396. }
  397. .uni-share-btn {
  398. height: 90upx;
  399. line-height: 90upx;
  400. border-top: 1px #f5f5f5 solid;
  401. text-align: center;
  402. color: #666;
  403. font-size: 30rpx;
  404. }
  405. </style>