invite.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view class="page">
  3. <headerline shownav=true isback="true" @tapnav="tapnav" :navstyle="navstyle" :navitem="navitem" :navselect="navselect" :statusbarheight='statusBarHeight' ></headerline>
  4. <block v-if="navselect==0">
  5. <view class="nodata" v-if="!list" >还有推广链接,<span style='color: #2319DC;' @tap="tapnav(1)">立即新增推广链接</span></view>
  6. <block v-else>
  7. <view v-for="(m,index) in list" :key='index' class="lists">
  8. <view>
  9. <span ><span class='title1'>类型:</span><view class="btn_green" v-if="m.isdaili==1">代理</view>
  10. <view class="btn_yellow" v-else>用户</view></span>
  11. <span ><span class='title1'>返点:</span><span style='color:#2319DC'>{{m.rebate}}%</span></span>
  12. </view>
  13. <view>
  14. <span ><span class='title1'>邀请码:</span>
  15. {{m.randcode}}
  16. <button class="btn1" @tap='copy(m.randcode)'>复制</button>
  17. </span>
  18. <span ><span class='title1'>发展人数:</span>
  19. {{m.regnum}}
  20. </span>
  21. </view>
  22. <view style='color:#777;font-size: 12px;'>
  23. <span >
  24. 发布时间:{{timestampToTime(m.addtime)}}
  25. </span>
  26. <span >
  27. <block v-if='m.remark'>备注:{{m.remark}}</block>
  28. </span>
  29. </view>
  30. <view class="btns">
  31. <button class="btn2" @tap="open_qrcode(m)">查看二维码</button>
  32. <button class="btn2" @tap="copy_url(m)">复制邀请链接</button>
  33. <button class="btn2 delete" @tap="delete_url(index,m)">
  34. <uni-icons type='closeempty'></uni-icons>
  35. 删除</button>
  36. </view>
  37. </view>
  38. </block>
  39. <view class="qrcode" v-if="showcode">
  40. <image :src="qrcode" class="code"></image>
  41. <image src="/static/close.png" class="close" @tap='showcode=false;'></image>
  42. </view>
  43. </block>
  44. <block v-else>
  45. <ul class="profile" >
  46. <li>用户类型:</li>
  47. <li>
  48. <radio :checked="form.isdaili==true" @tap="set_daili(true)" >代理</radio>
  49. <radio style="margin-left: 10px;" :checked="form.isdaili!=true" @tap="set_daili(false)" >用户</radio>
  50. </li>
  51. </ul>
  52. <ul class="profile" style='display: none;' >
  53. <li>返点比例:</li>
  54. <li>
  55. <picker @change="change_rebate" :value="rebate_index" :range="rebates" :disabled="rebate_disabled" style="display: inline-block;">
  56. <view class="uni-input">{{form.rebate}}%</view>
  57. </picker>
  58. <span style="margin-left:10px;color:#666;">
  59. (
  60. <block v-if="form.isdaili">
  61. 打赏分润占比
  62. </block>
  63. <block v-else>
  64. 用户账号无分润
  65. </block>
  66. </span>
  67. )
  68. </li>
  69. </ul>
  70. <ul class="profile" >
  71. <li>备注:</li>
  72. <li>
  73. <input type="text" style="width: 150px;" maxlength="10" class="input1" placeholder="请输入备注信息" v-model="form.remark"/>
  74. </li>
  75. </ul>
  76. <view style="margin:15px auto;display:block;width: 80%;">
  77. <button class="button1" @tap="click_sub()">确认并提交</button>
  78. </view>
  79. </block>
  80. <tabbar></tabbar>
  81. </view>
  82. </template>
  83. <script>
  84. import http from "../../library/http.js"
  85. import config from "../../config.js"
  86. import headerline from '../../components/header.vue'
  87. import uniIcons from '../../components/uni-icons/uni-icons.vue'
  88. import tabbar from '../../components/tabbar.vue'
  89. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight ;
  90. export default {
  91. components:{
  92. headerline ,
  93. uniIcons,
  94. tabbar
  95. },
  96. data() {
  97. return {
  98. statusBarHeight: statusBarHeight+ 'px',
  99. navitem:['我的邀请链接','新增邀请链接'],
  100. navselect:0,
  101. navstyle:"width:60%;left:20%",
  102. list:[],
  103. user:uni.getStorageSync('userInfo'),
  104. rebates:[],
  105. rebate_disabled:false,
  106. rebate_index:0,
  107. form:{
  108. remark:'',
  109. rebate:'',
  110. isdaili:true,
  111. userid:uni.getStorageSync('access_token')
  112. },
  113. showcode:false,
  114. qrcode:'',
  115. qrcode_id:''
  116. }
  117. },
  118. methods: {
  119. tapnav(num){
  120. this.navselect=num;
  121. if(num==1){
  122. this.form.rebate=this.user.rebate-0.5;
  123. this.rebates=[];
  124. for(var i=this.form.rebate;i>=0;i=i-0.5){
  125. this.rebates.push(i.toFixed(1));
  126. }
  127. }
  128. else{
  129. this.get_invite();
  130. }
  131. },
  132. set_daili(type){
  133. this.form.isdaili=type;
  134. if(type==true){
  135. this.form.rebate= this.rebates[this.rebate_index];
  136. this.rebate_disabled=false;
  137. }
  138. else{
  139. this.form.rebate=0;
  140. this.rebate_disabled=true;
  141. }
  142. },
  143. change_rebate(e){
  144. var index=e.detail.value;
  145. this.rebate_index=index;
  146. this.form.rebate= this.rebates[this.rebate_index];
  147. },
  148. click_sub(){
  149. this.form.userid=this.user.id;
  150. this.form.isdaili=this.form.isdaili?1:0;
  151. http.setWait(true).post('user.php?act=invite_add',this.form).then(res=>{
  152. if(res.code==200){
  153. uni.showToast({
  154. title:'操作成功',
  155. icon:'none',
  156. duration:2000
  157. })
  158. // this.list.push(res.data);
  159. // uni.setStorageSync('invite',this.list);
  160. this.tapnav(0);
  161. }
  162. })
  163. },
  164. get_invite(){
  165. http.setWait(false).get('user.php?act=invite_list',{userid:this.user.id}).then(res=>{
  166. if(res.code==200){
  167. this.list=res.data;
  168. uni.setStorageSync('invite',this.list);
  169. }
  170. })
  171. },
  172. timestampToTime(timestamp) {
  173. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  174. var Y = date.getFullYear() ;
  175. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
  176. var D = date.getDate();
  177. var h = date.getHours();
  178. var m = date.getMinutes();
  179. var s = date.getSeconds();
  180. if(D<10) D='0'+D;
  181. if(h<10) h='0'+h;
  182. if(m<10) m='0'+m;
  183. if(s<10) s='0'+s;
  184. return Y+'-'+M+'-'+D+' '+h+':'+m+':'+s ;
  185. },
  186. copy(data){
  187. uni.setClipboardData({
  188. data:data,
  189. success() {
  190. uni.showToast({
  191. title:'复制成功',
  192. icon:'none'
  193. })
  194. },
  195. fail: () => {
  196. uni.showToast({
  197. title:'复制失败',
  198. icon:'none'
  199. })
  200. }
  201. })
  202. },
  203. copy_url(m){
  204. var url=config.imgUri+"?from=invite&invite_code="+m.randcode;
  205. this.copy(url)
  206. },
  207. delete_url(index,m){
  208. uni.showModal({
  209. title: '提示',
  210. content: "确认要删除吗?",
  211. showCancel: true,
  212. cancelText: '取消',
  213. confirmText: '删除',
  214. success: res => {
  215. if(res.confirm) {
  216. this.list.splice(index,1);
  217. uni.setStorageSync('invite',this.list);
  218. http.setWait(false).get('user.php?act=invite_delete',{userid:this.user.id,id:m.id}).then(res=>{
  219. this.get_invite();
  220. })
  221. }
  222. }
  223. });
  224. },
  225. open_qrcode(m){
  226. this.showcode=true;
  227. if(this.qrcode_id!=m.id){
  228. this.qrcode_id=m.id;
  229. this.qrcode='';
  230. http.setWait(true).get('index.php?act=getMyQrcodeCard',{type:'qr_invite',code:m.randcode}).then(res=>{
  231. if(res.code==200){
  232. var img=res.data;
  233. if(img.indexOf('http')<=-1){
  234. img=config.apiUri+img;
  235. }
  236. this.qrcode=img;
  237. }
  238. })
  239. }else{
  240. }
  241. },
  242. },
  243. onLoad(opts) {
  244. this.user = uni.getStorageSync('userInfo');
  245. this.list=uni.getStorageSync('invite')?uni.getStorageSync('invite'):[];
  246. this.get_invite();
  247. },
  248. onNavigationBarButtonTap() {
  249. }
  250. }
  251. </script>
  252. <style lang="scss" scoped>
  253. @import "@/static/css/user.css";
  254. .page{
  255. background-color: #fafafa;
  256. }
  257. .profile,.login-lines1{
  258. background-color: #fff;
  259. margin: 10px auto;
  260. width: 100%;
  261. vertical-align: middle;
  262. }
  263. .profile li{
  264. vertical-align: middle;
  265. }
  266. .profile li:first-child{
  267. width:120px
  268. }
  269. .profile li:last-child{
  270. width:calc(100% - 130px)
  271. }
  272. .nodata{
  273. height: 40px;
  274. line-height: 40px;
  275. text-align: center;
  276. }
  277. .lists{
  278. background-color: #fff;
  279. margin-top: 10px;
  280. padding: 5px 10px;
  281. line-height: 25px;
  282. clear: both;
  283. display: inline-block;
  284. width: calc(100% - 20px);
  285. }
  286. .lists > view{
  287. clear: both;
  288. }
  289. .lists > view > span{
  290. display: inline-block;
  291. }
  292. .lists > view > span:first-child{
  293. text-align: left;
  294. float: left;
  295. }
  296. .lists > view > span:last-child{
  297. text-align: right;
  298. float: right;
  299. }
  300. .lists > view .title1{
  301. color: #666;
  302. }
  303. .btn1{
  304. display: inline-block;
  305. height: 22px;
  306. line-height: 22px;vertical-align: middle;font-size: 14px;
  307. margin-left: 4px;
  308. background-color: #f8f8f8;
  309. border: 1px #e7e7e7 solid;
  310. border-radius: 5px;
  311. }
  312. .btn2{
  313. display: inline-block;
  314. height: 28px;
  315. line-height: 28px;vertical-align: middle;font-size: 14px;
  316. margin-left: 4px;
  317. background-color: #2319dc;
  318. border: 1px #2319dc solid;
  319. color:#fff;
  320. border-radius: 5px;
  321. padding: 0px 10px;
  322. margin: 0px 15px;
  323. }
  324. .btn2.delete{
  325. background-color: #f8f8f8;
  326. border: 1px #e7e7e7 solid;
  327. color:#222;
  328. padding: 0px 10px;
  329. }
  330. .lists > view.btns{
  331. height: 30px;line-height: 30px;text-align: center;
  332. }
  333. .qrcode{
  334. background-color: rgba($color: #000000, $alpha: 0.5);
  335. position: fixed;
  336. left: 0px;
  337. width: 100%;
  338. height: 100vh;
  339. top:0px;
  340. }
  341. .qrcode .code{
  342. height: 200px;
  343. width: 200px;
  344. top:calc(50% - 150px);
  345. left: calc(50% - 100px);
  346. position: fixed;
  347. }
  348. .qrcode .close{
  349. bottom: 80px;;
  350. left: calc(50% - 20px);
  351. position: fixed;
  352. height: 40px;width: 40px;
  353. }
  354. .btn_yellow{
  355. background-color: yellow;
  356. color: #000;
  357. font-size: 12px;
  358. display: inline-block;
  359. height:18px;
  360. line-height: 18px;
  361. padding: 0px 5px;
  362. border-radius: 5px;
  363. text-align: center;
  364. margin: 0px 2px;
  365. }
  366. .btn_green{
  367. background-color: #0aad6c;
  368. color: #fff;font-size: 12px;
  369. display: inline-block;
  370. height: 18px;
  371. line-height: 18px;
  372. padding: 0px 5px;
  373. border-radius: 5px;
  374. text-align: center;
  375. margin: 0px 2px;
  376. }
  377. .btn_blue{
  378. background-color: #2319dc;
  379. color: #fff;font-size: 12px;
  380. display: inline-block;
  381. height: 18px;
  382. line-height: 18px;
  383. padding: 0px 5px;
  384. border-radius: 5px;
  385. text-align: center;
  386. margin: 0px 2px;
  387. }
  388. .btn_grey{
  389. background-color: #ddd;
  390. color: #000;font-size: 12px;
  391. display: inline-block;
  392. height: 18px;
  393. line-height: 18px;
  394. padding: 0px 5px;
  395. border-radius: 5px;
  396. text-align: center;
  397. margin: 0px 2px;
  398. }
  399. </style>