uni_android_plugin_project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <view class="uni-container">
  3. <view class="uni-hello-text">
  4. <text class="hello-text">uni原生插件示例1</text>
  5. </view>
  6. <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
  7. <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
  8. <text class="uni-panel-text">{{item.name}}</text>
  9. <text class="uni-panel-icon uni-icon" :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '&#xe581;' : '&#xe470;'}}</text>
  10. </view>
  11. <view class="uni-panel-c" v-if="item.open">
  12. <view class="uni-navigate-item" v-for="(item2,key) in item.pages" :key="key" @click="goDetailPage(item2.url)">
  13. <text class="uni-navigate-text">{{item2.name ? item2.name : item2}}</text>
  14. <text class="uni-navigate-icon uni-icon">&#xe470;</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="uni-panel">
  19. <view class="uni-panel-h" @click="testScanCancle()">testScanCancle</view>
  20. <view class="uni-panel-h" @click="goScan()">goScan</view>
  21. <view class="uni-panel-h" @click="goBallList()">goBallList</view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. list: [{
  30. id: 'ext-module',
  31. name: '扩展 module测试列表',
  32. open: false,
  33. url: '/pages/sample/ext-module-vue'
  34. },
  35. {
  36. id: 'ext-component',
  37. name: '扩展 component',
  38. open: false,
  39. url: '/pages/sample/ext-component'
  40. },
  41. {
  42. id:'richAlert',
  43. name:'插件示例RichAlert',
  44. open:false,
  45. url:'/pages/sample/richAlert'
  46. }],
  47. navigateFlag: false,
  48. }
  49. },
  50. onLoad() {
  51. },
  52. methods: {
  53. goScan(){
  54. console.log(111);
  55. uni.navigateTo({
  56. url:'./scan'
  57. })
  58. },
  59. goBallList(){
  60. console.log(111);
  61. uni.navigateTo({
  62. url:'./ball_list'
  63. })
  64. },
  65. testScanCancle(){
  66. // 只允许通过相机扫码
  67. uni.scanCode({
  68. onlyFromCamera: true,
  69. success: function (res) {
  70. console.log('条码类型:' + res.scanType);
  71. console.log('条码内容:' + res.result);
  72. }
  73. });
  74. setTimeout(()=>{
  75. console.log("执行返回");
  76. // uni.navigateBack({
  77. // delta:2
  78. // })
  79. uni.navigateBack()
  80. uni.navigateBack()
  81. },3000)
  82. },
  83. triggerCollapse(e) {
  84. if (!this.list[e].pages) {
  85. this.goDetailPage(this.list[e].url);
  86. return;
  87. }
  88. for (var i = 0; i < this.list.length; ++i) {
  89. if (e === i) {
  90. this.list[i].open = !this.list[e].open;
  91. } else {
  92. this.list[i].open = false;
  93. }
  94. }
  95. },
  96. goDetailPage(e) {
  97. if (this.navigateFlag) {
  98. return;
  99. }
  100. this.navigateFlag = true;
  101. uni.navigateTo({
  102. url: e
  103. });
  104. setTimeout(() => {
  105. this.navigateFlag = false;
  106. }, 200)
  107. return false;
  108. }
  109. }
  110. }
  111. </script>
  112. <style>
  113. #bcid {
  114. background:#0F0;
  115. height:480px;
  116. width:360px;
  117. }
  118. </style>