index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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">
  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. </view>
  27. </template>
  28. <script>
  29. var md5 = require("../../common/md5.js");
  30. export default {
  31. data() {
  32. return {
  33. title: 'Hello',
  34. pageInfo:{},
  35. productList:[
  36. {
  37. id:'1',
  38. imgUrl:'/static/bed-bg.png',
  39. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  40. price:'13999'
  41. },
  42. {
  43. id:'2',
  44. imgUrl:'/static/bed2-bg.png',
  45. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  46. price:'15999'
  47. },
  48. {
  49. id:'3',
  50. imgUrl:'/static/bed-bg.png',
  51. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  52. price:'16999'
  53. },
  54. {
  55. id:'4',
  56. imgUrl:'/static/bed2-bg.png',
  57. productTitle:'甜蜜瑞士系列床垫 卧室独立袋弹簧 护脊静音软硬适…',
  58. price:'18999'
  59. }
  60. ]
  61. }
  62. },
  63. onLoad() {
  64. this.loginRequest();
  65. this.getPageProductList();
  66. },
  67. onShareAppMessage() {
  68. console.log(111);
  69. return {
  70. title: '分销小助手',
  71. path:'/pages/index/index?inviteId=' + getApp().globalData.user_id
  72. }
  73. },
  74. methods: {
  75. loginRequest(){
  76. uni.login({
  77. success: (res) => {
  78. uni.request({
  79. url: getApp().globalData.shareUrl, //需要设置为全局
  80. method: 'POST',
  81. header: {
  82. 'content-type': 'application/x-www-form-urlencoded'
  83. },
  84. data: {
  85. method: 'login',
  86. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  87. code: res.code,
  88. sign: md5('login' + getApp().globalData.globalTimestamp)
  89. },
  90. success: res => {
  91. // 通过openid发起会员登录
  92. getApp().globalData.user_id = res.data.msg.id;
  93. getApp().globalData.open_id = res.data.msg.openid;
  94. getApp().globalData.isAuth = res.data.msg.auth_status === '1';
  95. getApp().globalData.user_name = res.data.msg.name;
  96. getApp().globalData.user_headUrl = res.data.msg.headimg;
  97. getApp().globalData.sessionId = res.data.msg.session_key;
  98. getApp().globalData.user_phone = res.data.msg.phone;
  99. // getApp().globalData.times = res.data.msg.times;
  100. // getApp().globalData.total_times = res.data.msg.total_times;
  101. this.getPageInfo(res.data.msg.id);
  102. }
  103. });
  104. }
  105. });
  106. },
  107. getPageInfo(uId){ //获取首页面基本信息接口
  108. let that = this;
  109. uni.request({
  110. url: getApp().globalData.shareUrl, //需要设置为全局
  111. method: 'POST',
  112. header: {
  113. 'content-type': 'application/x-www-form-urlencoded'
  114. },
  115. data: {
  116. method: 'getHomePageInfo',
  117. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  118. id: uId,
  119. sign: md5('getHomePageInfo' + getApp().globalData.globalTimestamp)
  120. },
  121. success: res => {
  122. if (res.data.code === 200) {
  123. that.pageInfo = res.data.msg
  124. console.log(res.data.msg)
  125. }
  126. }
  127. });
  128. },
  129. getPageProductList(){ //获取首页面产品列表接口
  130. uni.request({
  131. url: getApp().globalData.shareUrl, //需要设置为全局
  132. method: 'POST',
  133. header: {
  134. 'content-type': 'application/x-www-form-urlencoded'
  135. },
  136. data: {
  137. method: 'getProductsList',
  138. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  139. page: '',
  140. pageSize:'',
  141. sign: md5('getProductsList' + getApp().globalData.globalTimestamp)
  142. },
  143. success: res => {
  144. if (res.data.code === 200) {
  145. console.log(res.data.msg)
  146. }
  147. }
  148. });
  149. },
  150. goDetail(){
  151. uni.navigateTo({
  152. url: '/pages/index/detailPage/index',
  153. success: res => {},
  154. fail: () => {},
  155. complete: () => {}
  156. });
  157. },
  158. copyCode(){
  159. uni.setClipboardData({
  160. data:'xxx',
  161. success() {
  162. uni.showToast({
  163. icon:'none',
  164. title:'复制成功'
  165. })
  166. }
  167. })
  168. }
  169. }
  170. }
  171. </script>
  172. <style>
  173. .content {
  174. display: flex;
  175. flex-direction: column;
  176. align-items: center;
  177. justify-content: center;
  178. }
  179. .logo {
  180. height: 400px;
  181. width: 100%;
  182. margin-bottom: 30upx;
  183. }
  184. .share-box {
  185. display: flex;
  186. flex-direction: column;
  187. justify-content: center;
  188. align-items: center;
  189. width: 80%;
  190. height: 300upx;
  191. border: 1px dashed red;
  192. background: #fff;
  193. font-size: 28rpx;
  194. padding: 5px;
  195. }
  196. .share-box button {
  197. width: 300rpx;
  198. height: 70rpx;
  199. line-height: 70rpx;
  200. margin-top: 2%;
  201. background-color: #27BCEF;
  202. color: #fff;
  203. }
  204. .title {
  205. font-size: 36upx;
  206. color: #8f8f94;
  207. }
  208. .product-title {
  209. margin-left: -75%;
  210. margin-top: 5%;
  211. margin-bottom: 1%;
  212. }
  213. .recommend-box {
  214. display: flex;
  215. flex-direction: column;
  216. justify-content: center;
  217. align-items: center;
  218. }
  219. .product-box {
  220. width: 90%;
  221. height: 200rpx;
  222. padding: 20rpx;
  223. display: flex;
  224. align-items: center;
  225. background-color: #fff;
  226. border-radius:10px;
  227. margin-bottom: 2%;
  228. }
  229. .product-box image {
  230. width: 420rpx;
  231. height: 180rpx;
  232. margin-right: 5%;
  233. }
  234. .detail-box {
  235. display: flex;
  236. flex-direction: column;
  237. justify-content: space-between;
  238. font-size: 30rpx;
  239. height: 190rpx;
  240. }
  241. </style>