index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <view class="u-demo-result-line">
  7. {{result}}
  8. </view>
  9. </view>
  10. </view>
  11. <view class="u-config-wrap">
  12. <view class="u-config-title u-border-bottom">
  13. 参数配置
  14. </view>
  15. <view class="u-config-item">
  16. <view class="u-item-title">长度</view>
  17. <u-subsection current="2" :list="['10', '16', '32', 'rfc4122标准']" @change="lengthChange"></u-subsection>
  18. </view>
  19. <view class="u-config-item">
  20. <view class="u-item-title">首字符为"u"</view>
  21. <u-subsection :list="['是', '否']" @change="fristUChange"></u-subsection>
  22. </view>
  23. <view class="u-config-item">
  24. <view class="u-item-title">取值基数(进制)</view>
  25. <u-subsection current="3" :list="['二', '八', '十', '六十二']" @change="radixChange"></u-subsection>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. length: 32,
  35. firstU: true,
  36. radix: 62,
  37. result: null
  38. }
  39. },
  40. onLoad() {
  41. this.getResult();
  42. },
  43. methods: {
  44. lengthChange(index) {
  45. this.length = index == 0 ? 10 : index == 1 ? 16 : index == 2 ? 32 : null;
  46. this.getResult();
  47. },
  48. fristUChange(index) {
  49. this.firstU = index == 0 ? true : false;
  50. this.getResult();
  51. },
  52. radixChange(index) {
  53. this.radix = index == 0 ? 2 : index == 1 ? 8 : index == 2 ? 10 : 62;
  54. this.getResult();
  55. },
  56. getResult() {
  57. this.result = this.$u.guid(this.length, this.firstU, this.radix);
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. .u-demo {}
  64. </style>