nc-member-card.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view class="member-detail-wrap">
  3. <!-- 卡包 -->
  4. <uni-popup ref="cardlistPop">
  5. <view class="pop-box cardlistPop-box">
  6. <view class="pop-header">
  7. <view class="pop-header-text">卡包</view>
  8. <view class="pop-header-close" @click="close('cardlist')"><i class="iconguanbi1 iconfont"></i></view>
  9. </view>
  10. <scroll-view scroll-y="true" class="common-scrollbar pop-content">
  11. <dataTable url="/cardservice/storeapi/membercard/lists" :cols="card" ref="table" :option="option" :pagesize="pagesize">
  12. <template v-slot:action="dataTable">
  13. <text class="view-detail" @click="viewDetails(dataTable.value.card_id)">查看详情</text>
  14. </template>
  15. </dataTable>
  16. </scroll-view>
  17. </view>
  18. </uni-popup>
  19. <uni-popup ref="cardDetailPop">
  20. <view class="pop-box cardDetailPop-box">
  21. <view class="pop-header">
  22. <view class="pop-header-text">详情</view>
  23. <view class="pop-header-close" @click="$refs.cardDetailPop.close()"><i class="iconguanbi1 iconfont"></i></view>
  24. </view>
  25. <view class="pop-content">
  26. <view class="tab-head">
  27. <text
  28. v-for="(item, index) in tabObj.list"
  29. :key="index"
  30. :class="{ active: tabObj.index == item.value }"
  31. v-if="(item.value == 3 && card_detail.card_log && card_detail.card_log.length > 0) || item.value != 3"
  32. @click="tabObj.index = item.value"
  33. >
  34. {{ item.name }}
  35. </text>
  36. </view>
  37. <view class="tab-content">
  38. <view class="basic-info" v-if="tabObj.index == 0">
  39. <view class="basic-item using-hidden">卡项名称:{{ basicInfo.goods_name }}</view>
  40. <view class="basic-item">价格:{{ basicInfo.price }}</view>
  41. <view class="basic-item">
  42. 卡类型:{{
  43. (basicInfo.card_type == 'oncecard' && '限次卡') ||
  44. (basicInfo.card_type == 'timecard' && '限时卡') ||
  45. (basicInfo.card_type == 'commoncard' && '通用卡')
  46. }}
  47. </view>
  48. <view class="basic-item">总次数/已使用:{{ basicInfo.card_type == 'timecard' ? '不限' : basicInfo.total_num }}/{{ basicInfo.total_use_num }}</view>
  49. <view class="basic-item">获取时间:{{ $util.timeFormat(basicInfo.create_time) }}</view>
  50. <view class="basic-item">到期时间:{{ basicInfo.end_time > 0 ? $util.timeFormat(basicInfo.end_time) : '永久有效' }}</view>
  51. </view>
  52. <view class="other-information" v-if="tabObj.index == 1 && basicInfo && basicInfo.card_item">
  53. <view class="information-head">
  54. <text>商品名称</text>
  55. <text>总次数/已使用</text>
  56. <text>有效期</text>
  57. </view>
  58. <view class="information-body">
  59. <view class="information-tr" v-for="(item, index) in basicInfo.card_item" :key="index">
  60. <text class="using-hidden">{{ item.sku_name }}</text>
  61. <text>{{ item.card_type == 'timecard' ? '不限' : item.num }} /{{ item.use_num }}</text>
  62. <text>{{ item.end_time > 0 ? $util.timeFormat(item.end_time) : '永久有效' }}</text>
  63. </view>
  64. <view class="information-tr empty" v-if="!basicInfo.card_item.length">
  65. <view class="iconfont iconwushuju"></view>
  66. <view>暂无数据</view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="card-info" v-if="tabObj.index == 2">
  71. <dataTable
  72. url="/cardservice/storeapi/membercard/records"
  73. :cols="cardInfo.card"
  74. ref="table"
  75. :option="cardInfo.option"
  76. :pagesize="cardInfo.pagesize"
  77. ></dataTable>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </uni-popup>
  83. </view>
  84. </template>
  85. <script>
  86. import dataTable from '@/components/uni-data-table/uni-data-table.vue';
  87. export default {
  88. components: {
  89. dataTable
  90. },
  91. props: {
  92. option: {}
  93. },
  94. data() {
  95. return {
  96. pagesize: 8,
  97. card: [
  98. {
  99. width: 20,
  100. title: '名称',
  101. align: 'left',
  102. field: 'goods_name'
  103. },
  104. {
  105. width: 18,
  106. title: '卡号',
  107. align: 'center',
  108. field: 'card_code'
  109. },
  110. {
  111. width: 8,
  112. title: '卡类型',
  113. align: 'left',
  114. templet: function(data) {
  115. if (data.card_type == 'oncecard') return '限次卡';
  116. if (data.card_type == 'timecard') return '限时卡';
  117. if (data.card_type == 'commoncard') return '通用卡';
  118. }
  119. },
  120. {
  121. width: 12,
  122. title: '总次数/已使用',
  123. align: 'center',
  124. templet: data => {
  125. var totalNum = data.card_type == 'timecard' ? '不限' : data.total_num;
  126. return totalNum + '/' + data.total_use_num;
  127. }
  128. },
  129. {
  130. width: 17,
  131. title: '创建时间',
  132. align: 'center',
  133. templet: data => {
  134. return this.$util.timeFormat(data.create_time);
  135. }
  136. },
  137. {
  138. width: 17,
  139. title: '到期时间',
  140. align: 'center',
  141. templet: data => {
  142. if (data.end_time) return this.$util.timeFormat(data.end_time);
  143. else return '长期有效';
  144. }
  145. },
  146. {
  147. width: 8,
  148. title: '操作',
  149. align: 'right',
  150. action: true
  151. }
  152. ],
  153. tabObj: {
  154. list: [
  155. {
  156. value: 0,
  157. name: '基础信息'
  158. },
  159. {
  160. value: 1,
  161. name: '商品/项目'
  162. },
  163. {
  164. value: 2,
  165. name: '使用记录'
  166. }
  167. ],
  168. index: 1
  169. },
  170. currCardId: 0,
  171. basicInfo: {},
  172. cardInfo: {
  173. card: [
  174. {
  175. width: 40,
  176. title: '卡项名称',
  177. align: 'left',
  178. field: 'sku_name'
  179. },
  180. {
  181. width: 20,
  182. title: '使用次数',
  183. align: 'center',
  184. field: 'num'
  185. },
  186. {
  187. width: 25,
  188. title: '使用时间',
  189. align: 'right',
  190. templet: data => {
  191. return this.$util.timeFormat(data.create_time);
  192. }
  193. },
  194. {
  195. width: 15,
  196. title: '操作',
  197. align: 'right',
  198. action: true
  199. }
  200. ],
  201. option: {},
  202. pagesize: 6
  203. }
  204. };
  205. },
  206. created() {},
  207. methods: {
  208. open() {
  209. this.$refs.cardlistPop.open();
  210. },
  211. close() {
  212. this.$refs.cardlistPop.close();
  213. },
  214. viewDetails(card_id) {
  215. this.currCardId = card_id;
  216. this.$refs.cardDetailPop.open();
  217. this.getCardDetail();
  218. this.cardInfo.option.member_id = this.memberInfo.member_id;
  219. this.cardInfo.option.card_id = this.currCardId;
  220. },
  221. getCardDetail() {
  222. let data = {};
  223. data.member_id = this.memberInfo.member_id;
  224. data.card_id = this.currCardId;
  225. this.$api.sendRequest({
  226. url: '/cardservice/storeapi/membercard/detail',
  227. data: data,
  228. success: res => {
  229. this.basicInfo = {};
  230. if (res.code >= 0) {
  231. this.basicInfo = res.data;
  232. }
  233. }
  234. });
  235. }
  236. }
  237. };
  238. </script>
  239. <style lang="scss">
  240. // pop弹框
  241. .pop-box {
  242. background: #ffffff;
  243. width: 8rem;
  244. height: 7rem;
  245. .pop-header {
  246. padding: 0 0.15rem 0 0.2rem;
  247. height: 0.5rem;
  248. line-height: 0.5rem;
  249. border-bottom: 0.01rem solid #f0f0f0;
  250. font-size: 0.14rem;
  251. color: #333;
  252. overflow: hidden;
  253. border-radius: 0.02rem 0.2rem 0 0;
  254. box-sizing: border-box;
  255. display: flex;
  256. justify-content: space-between;
  257. .pop-header-close {
  258. cursor: pointer;
  259. i {
  260. font-size: 0.18rem;
  261. }
  262. }
  263. }
  264. .pop-content {
  265. height: calc(100% - 1rem);
  266. overflow-y: scroll;
  267. padding: 0.1rem 0.2rem;
  268. box-sizing: border-box;
  269. }
  270. .pop-bottom {
  271. button {
  272. width: 95%;
  273. }
  274. }
  275. }
  276. .cardlistPop-box {
  277. width: 10rem;
  278. height: 5.7rem;
  279. .pop-content {
  280. height: calc(100% - 0.5rem);
  281. }
  282. /deep/ .tpage {
  283. position: absolute;
  284. right: 0;
  285. bottom: 0;
  286. }
  287. .basic-box {
  288. display: flex;
  289. justify-content: space-between;
  290. margin-bottom: 0.2rem;
  291. padding: 0.2rem;
  292. box-sizing: border-box;
  293. }
  294. .basic {
  295. padding: 0.1rem;
  296. margin-bottom: 0.5rem;
  297. }
  298. }
  299. .cardDetailPop-box {
  300. width: 10rem;
  301. height: 5.7rem;
  302. .tab-head {
  303. display: flex;
  304. background-color: #f7f8fa;
  305. text {
  306. height: 0.5rem;
  307. line-height: 0.5rem;
  308. text-align: center;
  309. padding: 0 0.35rem;
  310. box-sizing: border-box;
  311. &.active {
  312. background-color: #fff;
  313. }
  314. }
  315. }
  316. .pop-content {
  317. overflow-y: inherit;
  318. .basic-info {
  319. display: flex;
  320. flex-wrap: wrap;
  321. justify-content: space-between;
  322. padding: 0.2rem;
  323. .basic-item {
  324. flex-basis: 33%;
  325. height: 0.4rem;
  326. line-height: 0.4rem;
  327. }
  328. }
  329. }
  330. .other-information {
  331. display: flex;
  332. justify-content: space-between;
  333. flex-direction: column;
  334. padding-top: 0.2rem;
  335. .information-head {
  336. display: flex;
  337. justify-content: space-between;
  338. background-color: #f7f8fa;
  339. text {
  340. padding: 0 0.2rem;
  341. height: 0.5rem;
  342. line-height: 0.5rem;
  343. &:nth-child(1) {
  344. flex-basis: 35%;
  345. }
  346. &:nth-child(2) {
  347. flex-basis: 35%;
  348. }
  349. &:nth-child(2) {
  350. flex-basis: 30%;
  351. }
  352. }
  353. }
  354. .information-tr {
  355. display: flex;
  356. justify-content: space-between;
  357. border-bottom: 0.01rem solid #e6e6e6;
  358. text {
  359. padding: 0 0.2rem;
  360. height: 0.5rem;
  361. line-height: 0.5rem;
  362. &:nth-child(1) {
  363. flex-basis: 35%;
  364. }
  365. &:nth-child(2) {
  366. flex-basis: 35%;
  367. }
  368. &:nth-child(2) {
  369. flex-basis: 30%;
  370. }
  371. }
  372. &.empty {
  373. display: flex;
  374. justify-content: center;
  375. align-items: center;
  376. height: 0.5rem;
  377. color: #909399;
  378. .iconfont {
  379. font-size: 0.25rem;
  380. margin: 0.05rem;
  381. }
  382. }
  383. }
  384. }
  385. .card-info {
  386. display: flex;
  387. justify-content: space-between;
  388. padding-top: 0.2rem;
  389. }
  390. }
  391. .view-detail {
  392. color: $primary-color;
  393. }
  394. </style>