sugarList.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view>
  3. <!-- <list>
  4. 注意事项: 不能使用 index 作为 key 的唯一标识 -->
  5. <!-- <cell v-for="(item, index) in sugarList" :key="item.id">
  6. <text>{{item.productName}}</text>
  7. </cell>
  8. </list> -->
  9. <view class="" style="padding: 10upx;">
  10. </view>
  11. <view class="sugar" v-for="(item,index) in sugarList" :key="index">
  12. {{item.productName}}
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. sugarList:[]
  21. }
  22. },
  23. onShow() {
  24. var token = uni.getStorageSync("token");
  25. uni.setNavigationBarTitle({
  26. title: this.$t('dosugar.list')
  27. });
  28. if (token.length > 1) {
  29. this.selectSugarList();
  30. } else {
  31. uni.reLaunch({
  32. url: '../Login/Login',
  33. });
  34. }
  35. },
  36. methods: {
  37. selectSugarList(){
  38. var globalUser = uni.getStorageSync("globalUser");
  39. var token = uni.getStorageSync("token");
  40. uni.request({
  41. url: this.serverurl + '/TSugarDo/selectSugarList',
  42. data: {
  43. "adminId": globalUser.id
  44. },
  45. header: {
  46. 'token': token
  47. },
  48. method: "GET",
  49. success: (res) => {
  50. this.sugarList = res.data.data;
  51. },
  52. });
  53. }
  54. }
  55. }
  56. </script>
  57. <style>
  58. .sugar{
  59. padding-top: 8upx;
  60. padding-bottom: 8upx;
  61. text-align:center;
  62. color: #363D44;
  63. font-size: 28upx;
  64. font-family: "PingFang-SC-Medium";
  65. }
  66. </style>