coupon.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div>
  3. <nut-docheader
  4. :name="$route.name"
  5. :chName="$route.params.chnName"
  6. type="Component"
  7. desc="优惠券,包括京券、东券、运费券、不可用券,支持领取、选中事件。"
  8. :showQrCode="true"></nut-docheader>
  9. <h5>示例</h5>
  10. <!-- <a class="button button-primary" href="/demo.html#/Coupon" target="_blank">Demo</a> -->
  11. <h6>优惠券展示:京券,立即使用</h6>
  12. <nut-codebox :code="demo1" :imgUrl="['../asset/img/demo/coupon1.png']"></nut-codebox>
  13. <nut-codebox :code="demo11"></nut-codebox>
  14. <h6>优惠券展示:东券,立即使用</h6>
  15. <nut-codebox :code="demo2" :imgUrl="['../asset/img/demo/coupon2.png']"></nut-codebox>
  16. <nut-codebox :code="demo21"></nut-codebox>
  17. <h6>优惠券展示:运费券,立即使用</h6>
  18. <nut-codebox :code="demo3" :imgUrl="['../asset/img/demo/coupon3.png']"></nut-codebox>
  19. <nut-codebox :code="demo31"></nut-codebox>
  20. <h6>优惠券展示:不可用券</h6>
  21. <nut-codebox :code="demo4" :imgUrl="['../asset/img/demo/coupon4.png']"></nut-codebox>
  22. <nut-codebox :code="demo41"></nut-codebox>
  23. <h6>优惠券展示:切换状态</h6>
  24. <nut-codebox :code="demo5" :imgUrl="['../asset/img/demo/coupon5.png']"></nut-codebox>
  25. <nut-codebox :code="demo51"></nut-codebox>
  26. <h6>优惠券展示:有活动角标</h6>
  27. <nut-codebox :code="demo6" :imgUrl="['../asset/img/demo/coupon6.png']"></nut-codebox>
  28. <nut-codebox :code="demo61"></nut-codebox>
  29. <h5>Props</h5>
  30. <div class="tbl-wrapper">
  31. <table class="u-full-width">
  32. <thead>
  33. <tr>
  34. <th>参数</th>
  35. <th>说明</th>
  36. <th>类型</th>
  37. <th>默认值</th>
  38. <th>可选值</th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. <tr>
  43. <td>datas</td>
  44. <td>券数据</td>
  45. <td>Object</td>
  46. <td>--</td>
  47. <td>--</td>
  48. </tr>
  49. <tr>
  50. <td>datas.id</td>
  51. <td>优惠券Id</td>
  52. <td>Number</td>
  53. <td>--</td>
  54. <td>--</td>
  55. </tr>
  56. <tr>
  57. <td>datas.discount</td>
  58. <td>折扣金额</td>
  59. <td>Number</td>
  60. <td>--</td>
  61. <td>--</td>
  62. </tr>
  63. <tr>
  64. <td>datas.quota</td>
  65. <td>满额值</td>
  66. <td>Number</td>
  67. <td>--</td>
  68. <td>--</td>
  69. </tr>
  70. <tr>
  71. <td>datas.couponType</td>
  72. <td>0京券 1东券 2免运费券</td>
  73. <td>Number</td>
  74. <td>--</td>
  75. <td>--</td>
  76. </tr>
  77. <tr>
  78. <td>datas.couponLimitInfo</td>
  79. <td>该券不可使用或者可以使用的说明</td>
  80. <td>String</td>
  81. <td>--</td>
  82. <td>--</td>
  83. </tr>
  84. <tr>
  85. <td>datas.beginTime</td>
  86. <td>优惠券使用的起始日期</td>
  87. <td>String</td>
  88. <td>--</td>
  89. <td>--</td>
  90. </tr>
  91. <tr>
  92. <td>datas.endTime</td>
  93. <td>优惠券使用的截止日期</td>
  94. <td>String</td>
  95. <td>--</td>
  96. <td>--</td>
  97. </tr>
  98. <tr>
  99. <td>datas.isUsed</td>
  100. <td>是否可用</td>
  101. <td>Boolean</td>
  102. <td>--</td>
  103. <td>--</td>
  104. </tr>
  105. <tr>
  106. <td>isSwitch</td>
  107. <td>是否切换到选择功能</td>
  108. <td>Boolean</td>
  109. <td>false</td>
  110. <td>true/false</td>
  111. </tr>
  112. <tr>
  113. <td>isBadge</td>
  114. <td>是否有角标</td>
  115. <td>Boolean</td>
  116. <td>false</td>
  117. <td>true/false</td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. </div>
  122. <h5>Events</h5>
  123. <div class="tbl-wrapper">
  124. <table class="u-full-width">
  125. <thead>
  126. <tr>
  127. <th>事件名</th>
  128. <th>说明</th>
  129. <th>回调参数</th>
  130. </tr>
  131. </thead>
  132. <tbody>
  133. <tr>
  134. <td>immediate-use</td>
  135. <td>点击立即使用时触发</td>
  136. <td>返回当前优惠券数据</td>
  137. </tr>
  138. <tr>
  139. <td>switch-use</td>
  140. <td>选中或不选中时触发</td>
  141. <td>返回当前优惠券数据和是否选中状态</td>
  142. </tr>
  143. </tbody>
  144. </table>
  145. </div>
  146. </div>
  147. </template>
  148. <script>
  149. export default {
  150. data(){
  151. return{
  152. demo1: `<nut-coupon
  153. :datas="beanData"
  154. @immediate-use="immediateUse">
  155. </nut-coupon>`,
  156. demo2: `<nut-coupon
  157. :datas="beanData"
  158. @immediate-use="immediateUse">
  159. </nut-coupon>`,
  160. demo3: `<nut-coupon
  161. :datas="beanData"
  162. @immediate-use="immediateUse">
  163. </nut-coupon>`,
  164. demo4: `<nut-coupon
  165. :datas="beanData"
  166. @immediate-use="immediateUse">
  167. </nut-coupon>`,
  168. demo5: `<nut-coupon
  169. :datas="beanData"
  170. :is-switch="true"
  171. @switch-use="switchUse">
  172. </nut-coupon>`,
  173. demo6: `<nut-coupon
  174. :datas="beanData"
  175. :is-switch="true"
  176. @switch-use="switchUse"
  177. :is-badge="true">
  178. </nut-coupon>`,
  179. demo11: `export default {
  180. data(){
  181. return{
  182. beanData: {
  183. 'id': 1,
  184. 'discount': 100,
  185. 'quota': 400,
  186. 'couponType': 0,
  187. 'couponLimitInfo': '限自营好丽友商品',
  188. 'beginTime': '2015.07.07',
  189. 'endTime': '2015.07.07',
  190. 'isUsed': true
  191. }
  192. }
  193. },
  194. methods:{
  195. immediateUse(datas){
  196. console.log('立即使用,数据如下:' + JSON.stringify(datas));
  197. }
  198. }
  199. }`,
  200. demo21: `export default {
  201. data(){
  202. return{
  203. beanData: {
  204. 'id': 2,
  205. 'discount': 10,
  206. 'quota': 60,
  207. 'couponType': 1,
  208. 'couponLimitInfo': '限自营盼盼品牌部分饼干类商品',
  209. 'beginTime': '2015.07.07',
  210. 'endTime': '2015.07.07',
  211. 'isUsed': true
  212. }
  213. }
  214. },
  215. methods:{
  216. immediateUse(datas){
  217. console.log('立即使用,数据如下:' + JSON.stringify(datas));
  218. }
  219. }
  220. }`,
  221. demo31: `export default {
  222. data(){
  223. return{
  224. beanData: {
  225. 'id': 3,
  226. 'discount': 10,
  227. 'quota': 400,
  228. 'couponType': 2,
  229. 'couponLimitInfo': '限自营好丽友、盼盼品牌部分饼干类商品',
  230. 'beginTime': '2015.07.07',
  231. 'endTime': '2015.07.07',
  232. 'isUsed': true
  233. }
  234. }
  235. },
  236. methods:{
  237. immediateUse(datas){
  238. console.log('立即使用,数据如下:' + JSON.stringify(datas));
  239. }
  240. }
  241. }`,
  242. demo41: `export default {
  243. data(){
  244. return{
  245. beanData: {
  246. 'id': 4,
  247. 'discount': 10,
  248. 'quota': 400,
  249. 'couponType': 1,
  250. 'couponLimitInfo': '限自营好丽友、盼盼品牌部分饼干类商品',
  251. 'beginTime': '2015.07.07',
  252. 'endTime': '2015.07.07',
  253. 'isUsed': false
  254. }
  255. }
  256. },
  257. methods:{
  258. immediateUse(datas){
  259. console.log('立即使用,数据如下:' + JSON.stringify(datas));
  260. }
  261. }
  262. }`,
  263. demo51: `export default {
  264. data(){
  265. return{
  266. beanData: {
  267. 'id': 3,
  268. 'discount': 10,
  269. 'quota': 400,
  270. 'couponType': 2,
  271. 'couponLimitInfo': '限自营好丽友商品',
  272. 'beginTime': '2015.07.07',
  273. 'endTime': '2015.07.07',
  274. 'isUsed': true
  275. }
  276. }
  277. },
  278. methods:{
  279. switchUse(datas, isChecked) {
  280. console.log('是否选中:' + isChecked);
  281. }
  282. }
  283. }`,
  284. demo61: `export default {
  285. data(){
  286. return{
  287. beanData: {
  288. 'id': 3,
  289. 'discount': 10,
  290. 'quota': 400,
  291. 'couponType': 2,
  292. 'couponLimitInfo': '限自营好丽友商品',
  293. 'beginTime': '2015.07.07',
  294. 'endTime': '2015.07.07',
  295. 'isUsed': true
  296. }
  297. }
  298. },
  299. methods:{
  300. switchUse(datas, isChecked) {
  301. console.log('是否选中:' + isChecked);
  302. }
  303. }
  304. }`
  305. }
  306. },
  307. methods:{
  308. immediateUse(datas){
  309. console.log('立即使用,数据如下:' + JSON.stringify(datas));
  310. },
  311. switchUse(datas, isChecked) {
  312. console.log('是否选中:' + isChecked);
  313. }
  314. }
  315. }
  316. </script>
  317. <style>
  318. </style>