index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <view class="content">
  3. <image class="logo" src="/static/post-bg.png"></image>
  4. <view class="share-box">
  5. <view>分销商分享给好友,好友购买产品成功后即可获</view>
  6. <view>得分享奖励</view>
  7. <view>单笔最高可赚¥200.00</view>
  8. <view>快去分享吧</view>
  9. <button type="default" open-type="share">分享</button>
  10. </view>
  11. <view class="share-box" style="height: 200upx;margin-top: 2%;" @longpress="copyCode">
  12. <view>长按复制框内整段文字,打开 [手淘] 即可购买</view>
  13. <view>¥kSfsDfrtrEjt¥</view>
  14. <button type="default" @click="copyCode">一键复制</button>
  15. </view>
  16. <view class="product-title">推荐产品</view>
  17. <!-- <view class="recommend-box">
  18. <view class="product-box" v-for="item in productList" :key="item.id" @click="goDetail(item.id)">
  19. <image :src="item.imgUrl"></image>
  20. <view class="detail-box">
  21. <view>{{item.productTitle}}</view>
  22. <view style="color: #999;">¥{{item.price}}</view>
  23. </view>
  24. </view>
  25. </view> -->
  26. <!-- <section class="PullScroll-Page"> -->
  27. <!-- <s-pull-scroll ref="pullScroll" :back-top="true" :pullDown="pullDown" :pullUp="loadData"> -->
  28. <view class="recommend-box">
  29. <view class="product-box" v-for="item in productList" :key="item.id" @click="goDetail(item.id)">
  30. <image :src="item.picture"></image>
  31. <view class="detail-box">
  32. <view>{{item.desc || '-'}}</view>
  33. <view style="color: #999;">¥{{item.money || '-'}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- </s-pull-scroll> -->
  38. <!-- </section> -->
  39. </view>
  40. </template>
  41. <script>
  42. var md5 = require("../../common/md5.js");
  43. import sPullScroll from '@/components/s-pull-scroll';
  44. export default {
  45. components: {
  46. sPullScroll
  47. },
  48. data() {
  49. return {
  50. title: 'Hello',
  51. pageInfo:{},
  52. productList:[
  53. {
  54. id:'1',
  55. imgUrl:'/static/bed-bg.png',
  56. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  57. price:'13999'
  58. },
  59. {
  60. id:'2',
  61. imgUrl:'/static/bed2-bg.png',
  62. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  63. price:'15999'
  64. },
  65. {
  66. id:'3',
  67. imgUrl:'/static/bed-bg.png',
  68. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  69. price:'16999'
  70. },
  71. {
  72. id:'4',
  73. imgUrl:'/static/bed2-bg.png',
  74. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  75. price:'18999'
  76. }
  77. ]
  78. }
  79. },
  80. onLoad(options) {
  81. //this.refresh();
  82. getApp().globalData.lastId = options.inviteId ? options.inviteId : getApp().globalData.user_id
  83. this.loginRequest();
  84. this.getPageProductList();
  85. },
  86. onShareAppMessage() {
  87. return {
  88. title: '分销小助手',
  89. path:'/pages/index/index?inviteId=' + getApp().globalData.user_id
  90. }
  91. },
  92. methods: {
  93. loginRequest(){
  94. uni.login({
  95. success: (res) => {
  96. uni.request({
  97. url: getApp().globalData.shareUrl, //需要设置为全局
  98. method: 'POST',
  99. header: {
  100. 'content-type': 'application/x-www-form-urlencoded'
  101. },
  102. data: {
  103. method: 'login',
  104. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  105. code: res.code,
  106. sign: md5('login' + getApp().globalData.globalTimestamp)
  107. },
  108. success: res => {
  109. // 通过openid发起会员登录
  110. getApp().globalData.user_id = res.data.msg.id;
  111. getApp().globalData.open_id = res.data.msg.openid;
  112. getApp().globalData.isAuth = res.data.msg.auth_status === '1';
  113. getApp().globalData.user_name = res.data.msg.name;
  114. getApp().globalData.user_headUrl = res.data.msg.headimg;
  115. getApp().globalData.session_key = res.data.msg.session_key;
  116. getApp().globalData.user_phone = res.data.msg.phone;
  117. getApp().globalData.user_status = res.data.msg.status;
  118. // getApp().globalData.times = res.data.msg.times;
  119. // getApp().globalData.total_times = res.data.msg.total_times;
  120. this.getPageInfo(res.data.msg.id);
  121. }
  122. });
  123. }
  124. });
  125. },
  126. getPageInfo(uId){ //获取首页面基本信息接口
  127. let that = this;
  128. uni.request({
  129. url: getApp().globalData.shareUrl, //需要设置为全局
  130. method: 'POST',
  131. header: {
  132. 'content-type': 'application/x-www-form-urlencoded'
  133. },
  134. data: {
  135. method: 'getHomePageInfo',
  136. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  137. id: uId,
  138. sign: md5('getHomePageInfo' + getApp().globalData.globalTimestamp)
  139. },
  140. success: res => {
  141. if (res.data.code === 200) {
  142. that.pageInfo = res.data.msg
  143. console.log(res.data.msg)
  144. }
  145. }
  146. });
  147. },
  148. getPageProductList(pullScroll){ //获取首页面产品列表接口
  149. console.log(pullScroll)
  150. let that = this;
  151. uni.request({
  152. url: getApp().globalData.shareUrl, //需要设置为全局
  153. method: 'POST',
  154. header: {
  155. 'content-type': 'application/x-www-form-urlencoded'
  156. },
  157. data: {
  158. method: 'getProductsList',
  159. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  160. // page: pullScroll.page,
  161. // pageSize:4,
  162. page:'',
  163. pageSize:'',
  164. sign: md5('getProductsList' + getApp().globalData.globalTimestamp)
  165. },
  166. success: res => {
  167. if (res.data.code === 200) {
  168. console.log(res.data.msg)
  169. that.productList = res.data.msg;
  170. // setTimeout(() => {
  171. // if (pullScroll.page == 1) {
  172. // this.productList = res.data.msg;
  173. // }
  174. // const curList = [];
  175. // for (let i = res.data.msg.length; i < res.data.msg.length + 4; i++) {
  176. // curList.push(i);
  177. // }
  178. // this.productList = this.productList.concat(curList);
  179. // if (this.productList.length > 60) {
  180. // // finish(boolean:是否显示finishText,默认显示)
  181. // pullScroll.finish(this.productList.length > 4);
  182. // } else {
  183. // pullScroll.success();
  184. // }
  185. // }, 500);
  186. }
  187. }
  188. });
  189. },
  190. goDetail(id){
  191. uni.navigateTo({
  192. url: '/pages/index/detailPage/index?detailId='+id,
  193. success: res => {},
  194. fail: () => {},
  195. complete: () => {}
  196. });
  197. },
  198. copyCode(){
  199. uni.setClipboardData({
  200. data:'xxx',
  201. success() {
  202. uni.showToast({
  203. icon:'none',
  204. title:'复制成功'
  205. })
  206. }
  207. })
  208. },
  209. refresh () {
  210. this.$nextTick(() => {
  211. this.$refs.pullScroll.refresh();
  212. });
  213. },
  214. pullDown (pullScroll) {
  215. setTimeout(() => {
  216. this.loadData(pullScroll);
  217. }, 200);
  218. },
  219. loadData (pullScroll) {
  220. this.getPageProductList(pullScroll)
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss">
  226. // .PullScroll-Page {
  227. // padding: 40rpx;
  228. // .btn {
  229. // width: 100%;
  230. // height: 80rpx;
  231. // font-size: 28rpx;
  232. // &:not(:first-child) {
  233. // margin-top: 40rpx;
  234. // }
  235. // }
  236. // }
  237. .content {
  238. display: flex;
  239. flex-direction: column;
  240. align-items: center;
  241. justify-content: center;
  242. }
  243. .logo {
  244. height: 400px;
  245. width: 100%;
  246. margin-bottom: 30upx;
  247. }
  248. .share-box {
  249. display: flex;
  250. flex-direction: column;
  251. justify-content: center;
  252. align-items: center;
  253. width: 80%;
  254. height: 300upx;
  255. border: 1px dashed red;
  256. background: #fff;
  257. font-size: 28rpx;
  258. padding: 5px;
  259. }
  260. .share-box button {
  261. width: 300rpx;
  262. height: 70rpx;
  263. line-height: 70rpx;
  264. margin-top: 2%;
  265. background-color: #27BCEF;
  266. color: #fff;
  267. }
  268. .title {
  269. font-size: 36upx;
  270. color: #8f8f94;
  271. }
  272. .product-title {
  273. margin-left: -75%;
  274. margin-top: 5%;
  275. margin-bottom: 1%;
  276. }
  277. .recommend-box {
  278. width: 95%;
  279. display: flex;
  280. flex-direction: column;
  281. justify-content: center;
  282. align-items: center;
  283. }
  284. .product-box {
  285. width: 90%;
  286. height: 200rpx;
  287. padding: 20rpx;
  288. display: flex;
  289. align-items: center;
  290. background-color: #fff;
  291. border-radius:10px;
  292. margin-bottom: 2%;
  293. }
  294. .product-box image {
  295. width: 420rpx;
  296. height: 180rpx;
  297. margin-right: 5%;
  298. }
  299. .detail-box {
  300. display: flex;
  301. flex-direction: column;
  302. justify-content: space-between;
  303. font-size: 30rpx;
  304. height: 190rpx;
  305. }
  306. </style>