user_invite.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <view class="page">
  3. <view class="nodata" v-if="list.length<1" >{{opts.nickname}}没有任何直属下级</view>
  4. <block v-else>
  5. <view v-for="(m,index) in list" :key='index' class="lists" >
  6. <view >
  7. <image :src="image_cache(m.avatar)"></image>
  8. </view>
  9. <view>
  10. <view class="title" >{{m.nickname}}
  11. <span style="float:right;text-align: right;font-size: 14px;">
  12. 返点:{{m.rebate}}%
  13. <view class="btn_green" v-if="m.isdaili==1">代理</view>
  14. <view class="btn_yellow" v-else>用户</view>
  15. </span>
  16. </view>
  17. <view class="info">
  18. <span style="color: #666;font-size: 12px;">
  19. 注册:{{timestampToTime(m.regtime)}}
  20. </span>
  21. <view v-if="m.isvip==1" class="btn_blue">计划员</view>
  22. <span style="float:right;color: #666;font-size: 12px;text-align: right;">
  23. <view class="btn_green" @tap="user_invite(m)">查看下级</view>
  24. </span>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="loading" v-if="loading" >
  29. <view class="spinner">
  30. <view class="rect1"></view>
  31. <view class="rect2"></view>
  32. <view class="rect3"></view>
  33. <view class="rect4"></view>
  34. <view class="rect5"></view>
  35. </view>
  36. </view>
  37. <view class="nodata" v-if="nodate">{{opts.nickname}}共{{list.length}}个直属下级</view>
  38. <view class="nodata" v-else @tap="getnextpage">加载下一页</view>
  39. </block>
  40. </block>
  41. <tabbar></tabbar>
  42. </view>
  43. </template>
  44. <script>
  45. import http from "../../library/http.js"
  46. import config from "../../config.js"
  47. import tabbar from '../../components/tabbar.vue'
  48. import uniIcons from '../../components/uni-icons/uni-icons.vue'
  49. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight ;
  50. export default {
  51. components:{
  52. uniIcons,
  53. tabbar
  54. },
  55. data() {
  56. return {
  57. statusBarHeight: statusBarHeight+ 'px',
  58. list:[],
  59. opts:'',
  60. user:uni.getStorageSync('userInfo'),
  61. page:1,
  62. nodate:false,
  63. loading:false,
  64. }
  65. },
  66. methods: {
  67. user_invite(m){
  68. uni.navigateTo({
  69. url:'user_invite?id='+m.id+'&nickname='+m.nickname
  70. })
  71. },
  72. set_rebate(m){
  73. if(m.rebate<this.user.rebate - 0.5){
  74. var itemlist=[]
  75. for(var i=this.user.rebate - 0.5;i>m.rebate;i=i-0.5){
  76. itemlist.push(i.toFixed(1)+'%');
  77. }
  78. var that=this;
  79. uni.showActionSheet({
  80. itemList:itemlist,
  81. success: function (res) {
  82. var str=itemlist[res.tapIndex].replace('%','');
  83. str=parseFloat(str);
  84. http.setWait(false).post('user.php?act=set_rebate',{userid:m.id,rebate:str}).then(res=>{
  85. if(res.code==200){
  86. that.get_invite();
  87. uni.showToast({
  88. title:'设置成功',
  89. icon:'none'
  90. })
  91. }
  92. })
  93. }
  94. })
  95. }else{
  96. uni.showToast({
  97. title:'该用户返点已是最高,无需提升',
  98. icon:'none'
  99. })
  100. }
  101. },
  102. get_invite(){
  103. http.setWait(false).get('user.php?act=my_invite',{userid:this.opts.id,page:this.page}).then(res=>{
  104. if(res.code==200){
  105. this.loading=false;
  106. if(res.data.length>0){
  107. if(this.page==1){
  108. this.list=res.data;
  109. uni.setStorageSync('my_invite',this.list);
  110. }
  111. else{
  112. this.list.push(...res.data);
  113. }
  114. if(res.data.length<10) this.nodate=true;
  115. else
  116. this.nodate=false;
  117. }
  118. else{
  119. this.nodate=true;
  120. }
  121. }
  122. })
  123. },
  124. timestampToTime(timestamp) {
  125. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  126. var Y = date.getFullYear() ;
  127. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
  128. var D = date.getDate();
  129. var h = date.getHours();
  130. var m = date.getMinutes();
  131. var s = date.getSeconds();
  132. if(D<10) D='0'+D;
  133. if(h<10) h='0'+h;
  134. if(m<10) m='0'+m;
  135. if(s<10) s='0'+s;
  136. return Y+'-'+M+'-'+D+' '+h+':'+m+':'+s ;
  137. },
  138. open_detail(id){
  139. uni.navigateTo({
  140. url:'../friend/detail?from=invite&id='+id
  141. })
  142. },
  143. getnextpage(){
  144. //if(this.nodate==false){
  145. //this.page++;
  146. // this.get_invite();
  147. ///s}
  148. },
  149. },
  150. onLoad(opts) {
  151. this.user = uni.getStorageSync('userInfo');
  152. this.opts=opts;
  153. this.get_invite();
  154. uni.setNavigationBarTitle({
  155. title:opts.nickname+"的直属下级"
  156. })
  157. },
  158. onReachBottom() {
  159. },
  160. onNavigationBarButtonTap() {
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. @import "@/static/css/user.css";
  166. .page{
  167. background-color: #fafafa;
  168. }
  169. .nodata{
  170. height: 40px;
  171. line-height: 40px;
  172. text-align: center;
  173. }
  174. .lists{
  175. background-color: #fff;
  176. margin-top: 10px;
  177. padding: 5px 10px;
  178. line-height: 25px;
  179. clear: both;
  180. display: inline-block;
  181. width: calc(100% - 20px);
  182. height: 50px;
  183. }
  184. .lists > view{
  185. display: inline-block;
  186. padding-top: 0px;margin-top: 0px;
  187. vertical-align: top;
  188. }
  189. .lists > view:first-child{
  190. text-align: center;
  191. width:70px;
  192. }
  193. .lists > view:first-child image{
  194. height: 50px;
  195. width: 50px;
  196. vertical-align: top;
  197. border-radius: 5px;
  198. }
  199. .lists > view:last-child{
  200. text-align: left;
  201. width: calc(100% - 70px);
  202. }
  203. .lists > view:last-child .title{
  204. font-size: 16px;;
  205. }
  206. .lists > view:last-child .info{
  207. font-size: 12px;
  208. color: #666;
  209. }
  210. .btn1{
  211. display: inline-block;
  212. height: 22px;
  213. line-height: 22px;vertical-align: middle;font-size: 14px;
  214. margin-left: 4px;
  215. background-color: #f8f8f8;
  216. border: 1px #e7e7e7 solid;
  217. border-radius: 5px;
  218. }
  219. .btn2{
  220. display: inline-block;
  221. height: 28px;
  222. line-height: 28px;vertical-align: middle;font-size: 14px;
  223. margin-left: 4px;
  224. background-color: #2319dc;
  225. border: 1px #2319dc solid;
  226. color:#fff;
  227. border-radius: 5px;
  228. padding: 0px 10px;
  229. margin: 0px 15px;
  230. }
  231. .btn2.delete{
  232. background-color: #f8f8f8;
  233. border: 1px #e7e7e7 solid;
  234. color:#222;
  235. padding: 0px 10px;
  236. }
  237. .lists > view.btns{
  238. height: 30px;line-height: 30px;text-align: center;
  239. }
  240. .btn_yellow{
  241. background-color: yellow;
  242. color: #000;
  243. font-size: 12px;
  244. display: inline-block;
  245. height:18px;
  246. line-height: 18px;
  247. padding: 0px 5px;
  248. border-radius: 5px;
  249. text-align: center;
  250. margin: 0px 2px;
  251. }
  252. .btn_green{
  253. background-color: #0aad6c;
  254. color: #fff;font-size: 12px;
  255. display: inline-block;
  256. height: 18px;
  257. line-height: 18px;
  258. padding: 0px 5px;
  259. border-radius: 5px;
  260. text-align: center;
  261. margin: 0px 2px;
  262. }
  263. .btn_blue{
  264. background-color: #2319dc;
  265. color: #fff;font-size: 12px;
  266. display: inline-block;
  267. height: 18px;
  268. line-height: 18px;
  269. padding: 0px 5px;
  270. border-radius: 5px;
  271. text-align: center;
  272. margin: 0px 2px;
  273. }
  274. .btn_grey{
  275. background-color: #ddd;
  276. color: #000;font-size: 12px;
  277. display: inline-block;
  278. height: 18px;
  279. line-height: 18px;
  280. padding: 0px 5px;
  281. border-radius: 5px;
  282. text-align: center;
  283. margin: 0px 2px;
  284. }
  285. .loading {
  286. //loading动画
  287. display: flex;
  288. justify-content: center;
  289. padding-bottom: 20px;
  290. @keyframes stretchdelay {
  291. 0%,
  292. 40%,
  293. 100% {
  294. transform: scaleY(0.6);
  295. }
  296. 20% {
  297. transform: scaleY(1.0);
  298. }
  299. }
  300. .spinner {
  301. margin: 20upx 0;
  302. width: 60upx;
  303. height: 25px;
  304. display: flex;
  305. align-items: center;
  306. justify-content: space-between;
  307. view {
  308. background-color: #ff9800;
  309. height: 25px;
  310. width: 3px;
  311. border-radius: 3px;
  312. animation: stretchdelay 1.2s infinite ease-in-out;
  313. }
  314. .rect2 {
  315. animation-delay: -1.1s;
  316. }
  317. .rect3 {
  318. animation-delay: -1.0s;
  319. }
  320. .rect4 {
  321. animation-delay: -0.9s;
  322. }
  323. .rect5 {
  324. animation-delay: -0.8s;
  325. }
  326. }
  327. }
  328. </style>