beTest.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div>
  3. <!--测试-->
  4. <div style="position: relative;">
  5. {{testresult}}
  6. <div @click="testSaveGoods"> 点击测试货品保存testSaveGoods</div>
  7. <div @click="testReadGoods"> 点击测试货品数据读取 testReadGoods</div>
  8. <div @click="testSaveReview"> 点击测试货品数据读取testSaveReview</div>
  9. <div @click="testSaveWxid"> 点击测试货品数据读取testSaveWxid</div>
  10. <div @click="testReadWxid"> 点击测试WxID读取testReadWxid</div>
  11. <div @click="testSaveStorage"> 点击写入frontend-userid testSaveStorage</div>
  12. <div @click="testReadStorage"> 点击读取frontend-userid testReadStorage</div>
  13. </div>
  14. <van-button size="large" type="primary" @click="Toindex">返回首页</van-button>
  15. </div>
  16. </template>
  17. <script>
  18. import {
  19. Button
  20. } from 'vant'
  21. import {BasicFunction} from '../connector/basic-service';
  22. export default {
  23. name: "share",
  24. components: {
  25. [Button.name]: Button,
  26. },
  27. data() {
  28. return {
  29. testresult : '正在测试,请稍后',
  30. active: 0,
  31. share: require('../assets/post.png'),
  32. }
  33. },
  34. methods:{
  35. testSaveGoods(){
  36. window.testvuepage = this;
  37. BasicFunction.get_data("smartGoods/save", function(response){
  38. // console.log(response);
  39. if(response.ret !== "10000"){
  40. if(response.model.list.length > 0 && response.model === "1"){
  41. this.testSuccess();
  42. return;
  43. }
  44. this.testFailed();
  45. }else{
  46. // Test fail
  47. this.testFailed();
  48. }
  49. })
  50. },
  51. testReadGoods(){
  52. window.testvuepage = this;
  53. BasicFunction.get_data("smartGoods/list", function(response){
  54. // console.log(response);
  55. if(response.ret !== "10000"){
  56. if(response.model.list.length > 0 && response.model.list[0]["goodId"] != undefined){
  57. this.testSuccess();
  58. return;
  59. }
  60. this.testFailed();
  61. }else{
  62. // Test fail
  63. this.testFailed();
  64. return;
  65. }
  66. })
  67. },
  68. testSaveReview(){
  69. window.testvuepage = this;
  70. BasicFunction.get_data("/list", function(response){
  71. // console.log(response);
  72. if(response.ret !== "10000"){
  73. this.testSuccess();
  74. return;
  75. }else{
  76. // Test fail
  77. this.testFailed();
  78. return;
  79. }
  80. })
  81. },
  82. testSaveWxid(){
  83. window.testvuepage = this;
  84. BasicFunction.get_data("/list", function(response){
  85. // console.log(response);
  86. if(response.ret !== "10000"){
  87. this.testSuccess();
  88. return;
  89. }else{
  90. // Test fail
  91. this.testFailed();
  92. return;
  93. }
  94. })
  95. },
  96. testReadWxid(){
  97. window.testvuepage = this;
  98. BasicFunction.get_data("/list", function(response){
  99. // console.log(response);
  100. if(response.ret !== "10000"){
  101. this.testSuccess();
  102. return;
  103. }else{
  104. // Test fail
  105. this.testFailed();
  106. return;
  107. }
  108. })
  109. },
  110. testSaveStorage(){
  111. localStorage.setItem("xxx", "333");
  112. this.testSuccess();
  113. },
  114. testReadStorage(){
  115. window.testvuepage = this;
  116. if(localStorage.getItem("xxx") === "333") {
  117. this.testSuccess();
  118. }else{
  119. this.testSuccess();
  120. }
  121. },
  122. testSuccess (){
  123. Toast.success("测试成功", 4000);
  124. },
  125. testFail (){
  126. Toast.fail("测试失败", 4000);
  127. },
  128. Toindex(){
  129. this.$router.push('index');
  130. }
  131. }
  132. }
  133. </script>
  134. <style scoped>
  135. .van-button {
  136. background-color: #fd6740;
  137. border-color: #fd6740;
  138. margin: 10px 0 10px;
  139. width: 55%;
  140. }
  141. div {
  142. margin-top: 10px;
  143. background-color: white;
  144. border: solid 1px;
  145. padding: 10px;
  146. }
  147. </style>