agent.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <view>
  3. <!--标题栏-->
  4. <bar-title bgColor="bg-white" isBack title="代理">
  5. <block slot="content">代理</block>
  6. </bar-title>
  7. <view class="zaiui-user-info-box">
  8. <view class="cu-list menu-avatar">
  9. <view class="cu-item">
  10. <view class="cu-avatar round lg" :style="`background-image:url(${user.avatar || 'http://center.yuandaibao.com/data/yuandaibaov1/upload/1/92/4f/9e/924f9e2d2bd8fcdfea7af989db1a3f8a.jpg'});`"/>
  11. <view class="content text-xl">
  12. <view class="flex flex-direction" style="align-items: flex-start;">
  13. <text class="margin-right">{{user.name}}</text>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="zaiui-flex-tab show" style="padding-top: 40upx;">
  20. <view class="flex">
  21. <view class="basis-xxl">
  22. <scroll-view scroll-x class="nav z" scroll-with-animation>
  23. <block v-for="(item,index) in headTab.list" :key="item.id">
  24. <view class="cu-item" :class="item.id==headTab.TabCur?'select':''" @click="tabSelect" :data-id="item.id">
  25. <view>{{item.name}}</view>
  26. <view class="tab-dot bg-red"/>
  27. </view>
  28. </block>
  29. </scroll-view>
  30. </view>
  31. </view>
  32. </view>
  33. <block v-if="headTab.TabCur == 0">
  34. <view class="cu-list menu sm-border margin-top">
  35. <view class="cu-item">
  36. <view class="content">我的邀请码</view>
  37. <view class="action">
  38. <text class="text-gray">{{code}}<text class="cuIcon-copy" style="margin-left: 5px;"></text></text>
  39. </view>
  40. </view>
  41. <view class="cu-item">
  42. <view class="content">上级代理</view>
  43. <view class="action">
  44. <text class="text-red" v-if="parent == 2" @click="bottomModal=true">去绑定</text>
  45. <text class="text-gray" v-else>----</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="card" v-for="item in agentlist">
  50. <image class="card-bg" src="@/static/images/my/price_shape.png">
  51. <view class="flex hd">
  52. <view class="col">
  53. <view class="text-white h4">
  54. <text class="text-white cuIcon-agentcard"></text>
  55. {{item.name}}
  56. </view>
  57. </view>
  58. <view class="col text-end">
  59. <button class="cu-btn bg-red" data-type="agent" @click="handleBuy(item.id)">立即购买</button>
  60. </view>
  61. </view>
  62. <view class="detail">
  63. <view class="text-white price">价格<text>¥{{item.price}}</text></view>
  64. </view>
  65. <view class="detail">
  66. <view class="text-white" v-html="item.content"></view>
  67. </view>
  68. </view>
  69. </block>
  70. <block v-else>
  71. <view class="bg-white zaiui-news-list-box">
  72. <view class="margin-bottom cu-list menu-avatar">
  73. <view class="cu-item goods">
  74. <view class="cu-avatar round" style="background-image:url(/static/images/avatar/1.jpg);">
  75. </view>
  76. <view class="content">
  77. <view class="text-black">
  78. <text class="margin-right-xs">仔仔</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </block>
  85. <view class="cu-modal bottom-modal zaiui-bottom-modal-box" :class="bottomModal?'show':''">
  86. <view class="cu-dialog bg-white">
  87. <!--标题-->
  88. <view class="text-black text-center margin-tb text-lg zaiui-title-bar">
  89. <text>填写上级</text>
  90. <text class="cuIcon-close close-icon" @tap="bottomModal=false"></text>
  91. </view>
  92. <!--内容区域-->
  93. <view class="zaiui-modal-content" style="height: auto;">
  94. <view class="zaiui-view-box select" >
  95. <!--商品信息-->
  96. <view class="cu-list menu-avatar">
  97. <view class="cu-item" style="align-items: center;">
  98. <input type="text" style="flex:1" v-model="invite" placeholder="请输入上级邀请码" />
  99. </view>
  100. </view>
  101. </view>
  102. <view class="zaiui-footer-fixed">
  103. <view class="flex flex-direction">
  104. <button class="cu-btn bg-red lg" @click="bindParent">确定</button>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. import barTitle from '@/components/zaiui-common/basics/bar-title';
  114. import _tool from '@/static/zaiui/util/tools.js'; //工具函数
  115. export default {
  116. components: {
  117. barTitle
  118. },
  119. data() {
  120. return {
  121. skin: true,
  122. headTab: {
  123. list: [{
  124. id: 0,
  125. name: '代理信息'
  126. }, {
  127. id: 1,
  128. name: '邀请列表'
  129. }],
  130. TabCur: 0
  131. },
  132. user: {},
  133. place: {},
  134. agentlist: [],
  135. invitedlist: [],
  136. code: '',
  137. parent: '',
  138. bottomModal: false,
  139. invite: ''
  140. }
  141. },
  142. onLoad() {
  143. this.loadInfo()
  144. this.loadList()
  145. },
  146. onReady() {
  147. _tool.setBarColor(true);
  148. uni.pageScrollTo({
  149. scrollTop: 0,
  150. duration: 0
  151. });
  152. },
  153. methods: {
  154. loadInfo() {
  155. this.reqByuser({
  156. url: '?l=agent.info',
  157. data: {},
  158. success: res => {
  159. if(res.data.status == 1) {
  160. this.user = res.data.data.user;
  161. this.code = res.data.data.code;
  162. this.parent = res.data.data.parent;
  163. }else {
  164. uni.showToast({
  165. icon: 'error',
  166. title: res.data.msg
  167. })
  168. }
  169. }
  170. })
  171. },
  172. loadList() {
  173. this.reqByuser({
  174. url: '?l=agent.list',
  175. data: {},
  176. success: res => {
  177. if(res.data.status == 1) {
  178. this.agentlist = res.data.data.list;
  179. }else {
  180. uni.showToast({
  181. icon: 'error',
  182. title: res.data.msg
  183. })
  184. }
  185. }
  186. })
  187. },
  188. loadInvitedList() {
  189. this.reqByuser({
  190. url: '?l=agent.getChild',
  191. data: {},
  192. success: res => {
  193. if(res.data.status == 1) {
  194. this.invitedlist = res.data.data.list;
  195. }else {
  196. uni.showToast({
  197. icon: 'error',
  198. title: res.data.msg
  199. })
  200. }
  201. }
  202. })
  203. },
  204. handleBuy(id) {
  205. this.reqByuser({
  206. url: '?l=agent.buy',
  207. data: {
  208. id
  209. },
  210. success: res => {
  211. if(res.data.status == 1) {
  212. console.log(res.data.data)
  213. location.href = res.data.data.pay.link;
  214. }else {
  215. uni.showToast({
  216. icon: 'error',
  217. title: res.data.msg
  218. })
  219. }
  220. }
  221. })
  222. },
  223. tabSelect(e) {
  224. this.headTab.TabCur = e.currentTarget.dataset.id
  225. if(e.currentTarget.dataset.id == 1) {
  226. this.loadInvitedList()
  227. }
  228. },
  229. bindParent() {
  230. this.reqByuser({
  231. url: '?l=agent.addParent',
  232. data: {
  233. invite: this.invite
  234. },
  235. success: res => {
  236. if(res.data.status == 1) {
  237. uni.showToast({
  238. icon: 'success',
  239. title: '绑定成功'
  240. })
  241. this.loadInfo()
  242. }else {
  243. uni.showToast({
  244. icon: 'error',
  245. title: res.data.msg
  246. })
  247. }
  248. }
  249. })
  250. }
  251. }
  252. }
  253. </script>
  254. <style lang="scss">
  255. /* #ifdef APP-PLUS */
  256. @import "../../static/colorui/main.css";
  257. @import "../../static/colorui/icon.css";
  258. @import "../../static/zaiui/style/app.scss";
  259. /* #endif */
  260. @import "../../static/zaiui/style/goods.scss";
  261. </style>
  262. <style lang="scss" scoped>
  263. .card {
  264. position: relative;
  265. width: 680upx;
  266. height: 380upx;
  267. margin: 32upx auto 0;
  268. border-radius: 15upx;
  269. box-sizing: border-box;
  270. padding: 32upx;
  271. image {
  272. position: absolute;
  273. background-color: #0cbc87;
  274. width: 100%;
  275. border-radius: 15upx;
  276. height: 100%;
  277. left: 0;
  278. top: 0;
  279. opacity: 0.8;
  280. }
  281. &>view {
  282. position: relative;
  283. z-index: 1;
  284. }
  285. .hd {
  286. align-items: center;
  287. justify-content: space-between;
  288. margin-bottom: 40upx;
  289. .h4 {
  290. font-size: 40upx;
  291. font-weight: bolder;
  292. text {
  293. margin-right: 10upx;
  294. }
  295. }
  296. }
  297. .detail {
  298. display: flex;
  299. margin-bottom: 20upx;
  300. justify-content: space-between;
  301. .price {
  302. display: flex;
  303. flex-direction: column;
  304. width: 45%;
  305. font-size: 28upx;
  306. margin-right: 20upx;
  307. text {
  308. font-size: 40upx;
  309. margin-top: 5upx;
  310. &.through {
  311. text-decoration: line-through;
  312. font-size: 28upx;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. </style>
  319. <style lang="scss" scoped>
  320. .zaiui-news-box {
  321. width: 100%;
  322. display: none;
  323. .zaiui-follow-box {
  324. .action-text-cut {
  325. width: 70%;
  326. }
  327. }
  328. .zaiui-grid-menu {
  329. .cu-list.grid.no-border>.cu-item {
  330. .cu-avatar {
  331. margin: 0 auto;
  332. }
  333. }
  334. }
  335. .zaiui-news-list-box {
  336. padding: 0 9.09upx;
  337. .cu-list.menu-avatar>.cu-item>.cu-avatar {
  338. width: 81.81upx;
  339. height: 81.81upx;
  340. }
  341. .cu-list.menu-avatar>.cu-item {
  342. height: 163.63upx;
  343. align-items: inherit;
  344. .cu-avatar {
  345. margin-top: 25.45upx;
  346. .cu-tag.badge {
  347. width: 21.81upx;
  348. height: 21.81upx;
  349. top: 0;
  350. right: 0;
  351. border: 1.81upx solid #fff;
  352. }
  353. }
  354. .content {
  355. left: 136.36upx;
  356. margin-top: 18.18upx;
  357. width: calc(100% - 90.9upx - 54.54upx - 18.18upx);
  358. line-height: 1.7em;
  359. .cu-tag {
  360. padding: 0 3.63upx;
  361. text {
  362. position: relative;
  363. top: -2upx;
  364. }
  365. }
  366. }
  367. &:after {
  368. width: 0;
  369. height: 0;
  370. border-bottom: 0;
  371. }
  372. }
  373. .cu-list.menu-avatar>.cu-item.goods {
  374. .content {
  375. width: calc(100% - 309.09upx);
  376. }
  377. .action {
  378. position: absolute;
  379. right: 23.63upx;
  380. width: 127.27upx;
  381. .cu-avatar {
  382. width: 127.27upx;
  383. height: 127.27upx;
  384. margin-top: 18.18upx;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .zaiui-news-box.show {
  391. display: block;
  392. }
  393. </style>