index.vue 6.3 KB

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